react-native-radar
react-native-radar copied to clipboard
How can we tell when the user hasn't yet accepted or denied location permissions?
Summary
In my own project as well as the sample code, when the app runs for the first time, and location permissions have not yet been accepted or denied, getPermissionsStatus() returns DENIED. I'm used to other permissions requests providing a different value for if the user hasn't yet chosen either way (I figured this is what the UNKNOWN status would be for). Because of this, I can't tell whether the permissions were denied because the user actively denied them, or if they just weren't prompted yet, and I need to customize my app's messaging depending on whether the user is about to be prompted or not when I call requestPermissions()
, as the prompt will not appear if the permissions were actually denied.
Just in case I could use getLocation()
to make this determination, I checked both against these two cases.
Case 1: No option chosen yet for the location permission prompt
Result of getPermissionStatus()
: DENIED
Result of getLocation()
: ERROR_PERMISSIONS
Case 2: User rejected location permissions
Result of getPermissionStatus()
: DENIED
Result of getLocation()
: ERROR_PERMISSIONS
Thus, as far as I can tell, there is no way for me to tell if the user rejected permissions or hasn't yet chosen an option.
Code to reproduce
I just used the example from this repo, no changes, but I also saw the same thing when integrating the library into my own project
Steps to reproduce
- Download the example from this repo
- Yarn and
pod install
- Run it
- Check the console log messages for the output of
getPermissionsStatus()
OS version
macOS: 10.15.7 iOS: 14.3
SDK installation method
yarn / cocoapods
SDK version
3.0.6
Other information
@llamaluvr This is great feedback, thanks. We'll look into adding a NOT_DETERMINED
value in our next major release.
@llamaluvr This should be fixed in https://github.com/radarlabs/react-native-radar/pull/146