Prompt user to turn on GPS?

I know with Permissions.askAsync() we can prompt user to grant permission to access location.
The behaviors triggered by it are:

iOS

  • First time opening app:

    • If Settings → Privacy → Location Services is off, prompt user to enable it first and then prompt for permission.
    • If Settings → Privacy → Location Services is on, only prompt for permission.
  • Future usage of the app:

    • Not prompt at all when location is turned off. Permissions.askAsync() returns status = denied.

Android

  • First time opening app:

    • Only prompt for permission no matter location (GPS) is on or off.
  • Future usage of the app:

    • Not prompt at all when location (GPS) is off. Permissions.askAsync() returns status = granted.

Problem

On iOS:
The status returned by Permissions.askAsync() means if the user’s location is available.
denied could mean both no permission OR GPS is off.
granted means permission granted AND GPS is on.

Q1. How can I prompt user to turn on GPS when permission is granted BUT GPS is off on iOS?

On Android:
The status returned by Permissions.askAsync() means if the user has granted permission.
denied means no permission no matter GPS is on or off.
granted means permission granted no matter GPS is on or off.

Q2. How can I know whether GPS is on or off on Android?
Q3. How can I prompt user to turn on GPS when permission is granted BUT GPS is off on Android?


Expo.Permissions.askAsync(type)

Prompt the user for a permission. If they have already granted access, response will be success.

Expo.Location.getProviderStatusAsync() should provide this information in SDK 18 onward.

1 Like

Thanks! What is the expected release date of SDK 18?

end of the day tomorrow

1 Like

use this to turn gps on:

Location.enableNetworkProviderAsync()

It’s a simple popup. (without redirection to a setting)

I tried your solution to re-ask the user to enable the location when he presses no, but it only works 2 times when I click on the “NO” option. Can you help me?