Geocode coordinates access working in desktop browsers but not working in android browsers in react js code

15 Views Asked by At
const geolocation = (e) => {
    e.preventDefault();

    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(
            (success) => {
                const { latitude, longitude } = success.coords;
                setCordinates({ latitude, longitude });
                setL_status(true);
            },
            (error) => {
                alert("Something went wrong in the process of grabbing location: " + error.message);
                // Check if the user is on an Android device
            }
        );
    } else {
        alert("Geolocation is not supported by your browser.");
    }
};

This is my function to get coordinates of the user, but in Android browsers, I get this error:

only secure origin are allowed

Please help me solve this error

0

There are 0 best solutions below