4
 const granted = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, {
        title,
        message,
        buttonNeutral: "Ask Me Later",
        buttonNegative:"Cancel",
        buttonPositive: "OK"
 });

clicking buttonNegative & buttonNeutral button is expected to resolve promise immediately. instead it doesn't resolve promise and further asks for Permission from native dialog box.

Is it the expected behaviour? Not sure what are these two buttons for?

Surprisingly Official document also doesnt explain much about these two buttons.

shubhamkes
  • 516
  • 5
  • 12

1 Answers1

1

I ran the example on the official documentation on my device running Android 9. Upon pressing "REQUEST PERMISSIONS" button, I do get a custom pop up with three buttons. But none of the buttons actually does anything. Press any one of them, a new system-wide alert pops up asking me whether to grant, deny, or never ask again regarding the permission requested.

If grant or never ask again is pressed, further pressing "REQUEST PERMISSIONS" button does not show the pop up. And the request always returns "granted" or "never_ask_again". If deny is pressed, we go back to the situation mentioned in the first paragraph.

Judging from this behavior, the purpose of the custom pop up, at least on Android 9, is just for the rationale. The button (positive button in particular) allows a user to acknowledge that he/she knows about the reason behind the permission request. Yet the actual permission granting/denying should be handled by the system-wide pop up.

NOTE: you have to add <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> in AndroidMaanifest.xml in order to allow a permission to be requested. If not, the request will always return "never_ask_again".

Fanchen Bao
  • 3,310
  • 1
  • 21
  • 34