Search code examples
androidreact-nativepermissionsandroid-permissions

Unable to get callback of android permission when user agrees or rejects in React Native


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.


Solution

  • 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 in onRequestPermissionsResult, which caused react native to not call back the result after obtaining the permission.