Reputation: 1
I'm working with Expo SDK 42 and I'm having some problems retrieving specific data about the foreground location permission.
For ios, for example, when the user gets asked for permission, he gets 3 options: "allow once", "allow while using the app" or "don't allow".
The permission is being asked using the following method according to the documentation: requestForegroundPermissionsAsync()
. So after requesting it, if the user selects "allow once" or "allow while using the app", that method will return exactly the same object, which contains a property telling that the permission is 'granted', and there's no difference in the return value if the user selected one option or the other.
The problem is, I need to know and differentiate if the user selected "allow once" or "allow while using the app" because, based on that, I will show a different screen.
Do you know if it's possible to do that with Expo? If not, is there a workaround or something I can do to know what option was selected by the user?
Thank you.
Upvotes: -1
Views: 442
Reputation: 114992
The short answer is it isn't possible to differentiate between "allow while using" and "allow once", and your app really shouldn't need to anyway. If the user selects "allow once" then your app will just ask for access again the next time it launches.
Essentially your app needs to handle three states:
Initially your app will have the not determined state. In response you request location access. If the user selects "allow" or "allow once" you will get an access granted state.
If they selected "allow once" then the status will return to "not determined" the next time your app launches and you need to ask again.
If they select "allow while using" or "deny" then that state is what your app will see on subsequent launches unless the user goes into the settings for your app and changes it.
Upvotes: 0