question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android - Turn on Location Service popup not coming

See original GitHub issue

Hi,

My setup is

"dependencies": {
    "@react-native-community/geolocation": "^1.4.2",
    "react": "16.8.6",
    "react-native": "0.60.4",
    "react-native-geolocation-service": "^3.0.0",
    "react-native-gesture-handler": "^1.3.0",
    "react-navigation": "^3.11.1"
},

And code is:

Geolocation.getCurrentPosition(
    (position) => {
        console.warn("Position " + position.coords.latitude + " " + position.coords.longitude);
    },
    (error) => {
        // See error code charts below.
        console.warn("Error " + error.code, error.message);
    },
    { enableHighAccuracy: true, timeout: 15000, maximumAge: 10000, }
);

Scenario:

  1. I have already added code for PermissionsAndroid and after getting the permission I am hitting the above mentioned code.
  2. Android -

When the Location in top drawer menu is ON then I am getting location.

But when Location is off, it is not showing the following popup to ask user to enable the location service:

image

Instead, it directly goes to (error) and says, “error.code = 2, No location provider available.”

I think in earlier versions of library this used to work. But facing this problem in 3.0.0. 3. In iOS it is working fine. It is showing popup to ask for Permission for Location.

Any help on this would be appreciated.

P.S. @Agontuk Thanks for this library. We really appreciate your efforts.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:35 (10 by maintainers)

github_iconTop GitHub Comments

5reactions
Agontukcommented, Aug 30, 2019

Fixed in 3.1.0

5reactions
Agontukcommented, Aug 23, 2019

Guys, let me know if this flow makes sense. Looping in @cladjules since he implemented the forceRequestLocation feature.

  1. If location settings are ok, it’ll invoke success callback with location
  2. If not ok and showLocationDialog is false, it’ll invoke error callback with codeSETTINGS_NOT_SATISFIED.
  3. If not ok and showLocationDialog is true, it’ll show location popup to improve location accuracy.
  4. If user clicks OK, it’ll update the location settings and invoke success callback with location.
  5. If user clicks NO THANKS and forceRequestLocation is false, it’ll invoke error callback with codeSETTINGS_NOT_SATISFIED.
  6. If user clicks NO THANKS and forceRequestLocation is true but location provider is not enabled, it’ll invoke error callback with code POSITION_UNAVAILABLE.
  7. If user clicks NO THANKS and forceRequestLocation is true and location provider is enabled, it’ll invoke success callback with location if it’s possible.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Choose which apps use your Android phone's location
Find which apps use your phone's location · Swipe down from the top of the screen. · Touch and hold Location . ·...
Read more >
"Allow all the time" location prompt not coming in Android SDK ...
On Android 10+ Android first pops up the permission for location with three options. The user has to pick 'While using this app'....
Read more >
How to popup turn on device location dialog box - MSDN
I am using Visual Studio 2019 Xamarin Forms. How can I open the dialog box "to continue turn on device location which uses...
Read more >
'Google Location Service is disabled' alert keeps popping up
It sounds like your entire Location Service is turned off, not just GPS. Is that typical for you? It's possible for Location Service...
Read more >
Why am I getting an error asking me to enable location services?
If you haven't allowed your browser to access location services, then you will need to change the permissions: On Android devices: Within your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found