Reputation: 119
Say, I want to use Camera, but before opening Camera, App will request user permission.
If user deny to use camera, how can we know that ?
Upvotes: 0
Views: 2155
Reputation: 864
You can use this command to install android permission npm install react-native-android-permissions --save
.
Upvotes: 0
Reputation: 2383
There is no default way of doing this in React Native so you would need to create a Native Module which exposes AVCaptureDevice
to the Javascript layer of your app. Here is how to do that: https://facebook.github.io/react-native/docs/native-modules-ios.html
You could also use a third-party npm package for that.
You can check the authorization status of the AVCaptureDevice
using the authorizationStatus
method.
You can read more here: https://developer.apple.com/reference/avfoundation/avcapturedevice/1624613-authorizationstatus
If you want to check if user pressed Deny
you can do it in the completion handler of the AVCaptureDevice
method requestAccess
.
You can read about that here: https://developer.apple.com/reference/avfoundation/avcapturedevice/1624584-requestaccess
Upvotes: 0
Reputation: 119
Since there is not another solution, I will use react-native-permissions
instead.
Upvotes: 1