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
isoff
, prompt user to enable it first and then prompt for permission. - If Settings → Privacy →
Location Services
ison
, only prompt for permission.
- If Settings → Privacy →
-
Future usage of the app:
- Not prompt at all when location is turned
off
.Permissions.askAsync()
returns status =denied
.
- Not prompt at all when location is turned
Android
-
First time opening app:
- Only prompt for permission no matter
location (GPS)
is on or off.
- Only prompt for permission no matter
-
Future usage of the app:
- Not prompt at all when
location (GPS)
is off.Permissions.askAsync()
returns status =granted
.
- Not prompt at all when
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.