I use react-native-permissions to get the camera permission and it work well in iOS.
But I can’t get callback of android permission when user agrees or rejects.
I tried replacing it with PermissionsAndroid but I had the same issue.
Finally, I created a new project of React Native and using the same code I was able to get callback of android permission. What is the reason for this situation?
Note: Both projects use the same version of React Native.
2
Answers
I found that my problem came from the use of the onRequestPermissionsResult method in the original Android project, as long as I annotate it everything works fine.
I tried to understand the reason and found out that the previous maintenance project person did not write
super
inonRequestPermissionsResult
, which caused react native to not call back the result after obtaining the permission.android/app/src/main/AndroidManifest.xml
file. If not, then add it and rebuild your app.request()
will always beblocked
. In such case you should go app settings and change the permission manually.