React Native Permission rationale not showing

1.3k Views Asked by At

I'm having a trouble with react native permission rationale. It is not showing though I already put it in my code.

const rationale = { title: 'Permission', message: 'message' }
const res = await PermissionsAndroid.request(PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION, rationale);

What is the problem why it's not showing? Thank you for your help.

1

There are 1 best solutions below

0
On BEST ANSWER

Late reply, but perhaps this will help someone else who lands here in the future:

I struggled with this as well recently, until I dug into the documentation on PermissionsAndroid:

If rationale is provided, this function checks with the OS whether it is necessary to show a dialog explaining why the permission is needed (https://developer.android.com/training/permissions/requesting.html#explain) and then shows the system permission dialog.

While not immediately clear from that line alone, following the provided link to Google's Documentation yielded this valuable snippet:

If the ContextCompat.checkSelfPermission() method returns PERMISSION_DENIED, call shouldShowRequestPermissionRationale(). If this method returns true, show an educational UI to the user. In this UI, describe why the feature, which the user wants to enable, needs a particular permission.

Essentially, you won't see the rationale on the initial request; it will only be presented after the user has expressly denied the permission (either via the system dialog or through settings). Hope it helps!