Request user permissions from React Native, iOS + Android
- iOS: need add authorization’s key in info.plist
- android: need add permission in AndroidManifest.xml
# step 1
npm install react-native-authorization
# yarn add react-native-authorization
# step 2
react-native link react-native-authorization
import Helper from 'react-native-authorization'
Helper.check(Helper.CAMERA).then((r)=>{
console.log(r);
});
Methods
| Method Name | Arguments | Notes | iOS | android |
|---|---|---|---|---|
| check | type | Returns a promise | ✔️ | ✔️ |
| multipleCheck | [type1,type2] | Returns a promise | ❌ | ✔️ |
Check Type
| Name | iOS | android |
|---|---|---|
| CAMERA | ✔️ | ✔️ |
| LIBRARY | ✔️ | ❌ |
| LOCATION | ✔️ | ✔️ |
| ALWAYSLOCATION | ✔️ | ❌ |
| USELOCATION | ✔️ | ❌ |
| MIKE | ✔️ | ❌ |
| CALENDAR | ❌ | ✔️ |
| CONTACTS | ❌ | ✔️ |
| MICROPHONE | ❌ | ✔️ |
| PHONE | ❌ | ✔️ |
| SENSORS | ❌ | ✔️ |
| SMS | ❌ | ✔️ |
| STORAGE | ❌ | ✔️ |
Permission Result
| Result | Type | iOS | android |
|---|---|---|---|
Authorized |
string | ✔️ | ❌ |
AuthorizedAlways |
string | ✔️ | ❌ |
AuthorizedWhenInUse |
string | ✔️ | ❌ |
Denied |
string | ✔️ | ❌ |
NotDetermined |
string | ✔️ | ❌ |
Restricted |
string | ✔️ | ❌ |
true |
boolean | ❌ | ✔️ |
false |
boolean | ❌ | ✔️ |
Ruwei Li, [email protected]
react-native-authorization is available under the ISC license. See the LICENSE file for more info.