react-native
react-native copied to clipboard
PermissionsAndroid request returns "never_ask_again" on popup dismiss
Description
On Android 11, dismissing the request permission popup by tapping outside of it or by pressing the hardware back button will result on a never_ask_again
answer even if the permission is still requestable (it actually should be equal to denied
then).
On this version, the "Never ask again" checkbox disappear. The user have to press "Deny" twice to achieve the same effect. See https://developer.android.com/about/versions/11/privacy/permissions#dialog-visibility.
PS: Dismissing the popup isn't the same as pressing the "Deny" button, since requesting the permission is possible after multiple (2+) popup dimiss.
I made a GIF to illustrate the issue:
React Native version:
System:
OS: macOS 10.15.7
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Memory: 2.07 GB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.8.0
Yarn: 1.22.5
npm: 6.14.8
Watchman: 4.9.0
Managers:
CocoaPods: 1.9.3
SDKs:
iOS SDK:
Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
Android SDK:
API Levels: 21, 28, 29, 30
Build Tools: 27.0.3, 28.0.3, 29.0.1, 29.0.2, 29.0.3, 30.0.0, 30.0.2
System Images: android-21 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: 21.3.6528147
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6821437
Xcode: 12.0.1/12A7300
Languages:
Java: 1.8.0_265
Python: 2.7.17
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.3 => 0.63.3
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps To Reproduce
- Try to request a permission on Android 11+
- Dismiss the request popup by tapping outside of it or by pressing the hardware back button
- The request resolves with
never_ask_again
Expected Results
The permission is still requestable: It should resolves with denied
Any updated on this issue ?
I am also facing this issue...but I think this is an Android issue (not a React-Native one). These are my observations:
The documentation says that a permission request can be canceled (see here), in which case, the grantResults
array will be empty. However, if you dismiss the permission system dialog by clicking outside, the request isn't canceled. Instead, it is considered as a denial (grantResults[0]
is PackageManager.PERMISSION_DENIED
).
And something even stranger: although it is considered a denial, activity.shouldShowRequestPermissionRationale()
returns false
.
We follow the rule that if a permission was denied and if shouldShowRequestPermissionRationale
returned false, then this implies a NEVER_ASK_AGAIN
. So the logic is correct.
Android needs to either:
- Return an empty
grantResults
array when you click outside the permission alert - Make
shouldShowRequestPermissionRationale
return true after a clicked-outside-denial.
I am also facing this issue...but I think this is an Android issue (not a React-Native one). These are my observations:
The documentation says that a permission request can be canceled (see here), in which case, the
grantResults
array will be empty. However, if you dismiss the permission system dialog by clicking outside, the request isn't canceled. Instead, it is considered as a denial (grantResults[0]
isPackageManager.PERMISSION_DENIED
).And something even stranger: although it is considered a denial,
activity.shouldShowRequestPermissionRationale()
returnsfalse
.We follow the rule that if a permission was denied and if
shouldShowRequestPermissionRationale
returned false, then this implies aNEVER_ASK_AGAIN
. So the logic is correct.Android needs to either:
- Return an empty
grantResults
array when you click outside the permission alert- Make
shouldShowRequestPermissionRationale
return true after a clicked-outside-denial.
Then how is that in https://github.com/zoontek/react-native-permissions this problem is not present/was solved ?
I haven't looked closely at zoontek's implementation, but from what I saw, he's using a helper flag to check if the rationale was previously shown.
I don't like that approach because you have to consider many edge cases: what if you install an app, then immediately deny permissions from the settings without ever opening it, open it for the first time, and then request for permissions? Because of the boolean flag, now this returns "DENIED" instead of "NEVER_ASK_AGAIN".
@HectorRicardo Indeed. It's far from perfect, but Android 11+ is completely broken. What a shame.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
I'm also facing the exact same problem. Any solution for this?
I am not even getting popup can anyone know why??
I am not even getting popup can anyone know why??
same problem for me
Same problem here. I am asking multiple permissions, CAMERA
permission pop-up is opening and working fine, but for WRITE_EXTERNAL_STORAGE
and READ_EXTERNAL_STORAGE
permissions pop-up is not even opening and returning never_ask_again
. I think the issue is specific to devices because on majority of devices functionality is working, but on emulator and some devices, application is not functional due to this issue.
I am also facing this, I think it is specific to devices. In my case even the request permission pop is also not showing. I am facing this issue on android above 11.
I am also facing this, I think it is specific to devices. In my case even the request permission pop is also not showing. I am facing this issue on android above 11.
Same here
I am also facing this, I think it is specific to devices. In my case even the request permission pop is also not showing. I am facing this issue on android above 11.
Faced the same issue, found this: https://stackoverflow.com/a/73630987
From the Stackoverflow comment: we only need to ask for READ and WRITE Permission on Android API lower or equal 29.
However, still I get rejected without a popup opening on Android Api 30, 31, 32. 33 is working as it should when I set the targetSDK to 33 in the gradle.
Why is it simply rejecting the storage permissions for those three api levels inbetween?
I solved this by setting the Android Manifest:
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" /> <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" tools:replace="android:maxSdkVersion" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" tools:replace="android:maxSdkVersion" />
until 32 it would prompt and ask for permission now.
I tested from 32 down to 29, backward compatibility is given.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
Same problem here. I am asking multiple permissions,
CAMERA
permission pop-up is opening and working fine, but forWRITE_EXTERNAL_STORAGE
andREAD_EXTERNAL_STORAGE
permissions pop-up is not even opening and returningnever_ask_again
. I think the issue is specific to devices because on majority of devices functionality is working, but on emulator and some devices, application is not functional due to this issue.
do you got the solution for it?