Jonathan Lockley
Jonathan Lockley

Reputation: 1350

React native for Android navigator geolocation not running

On my iOS app the geolocation works fine and picks up my location on the watcher function.

However for Android, the code never seems to get executed on the success or fail callbacks when I put in alert's or console logs.

watchID: (null: ?number),

this.watchID = navigator.geolocation.watchPosition(
    (position) => {
        this.setState({ 
            userLocation: position,
            geo: true
        }, this.fetchBusinesses());
    },
    (error) => console.log(error.message),
    {enableHighAccuracy: true, timeout: 2000, maximumAge: 1000}
    );

Upvotes: 4

Views: 1670

Answers (1)

smoothdvd
smoothdvd

Reputation: 2448

If you are running with newest Android, you manual set "Location" to on. This switch is under Setting -> Apps -> {Your app} -> Permissions.enter image description here

Upvotes: 3

Related Questions