|
|
@@ -12,6 +12,7 @@ The current supported permissions are:
|
|
|
- Bluetooth *(iOS only)*
|
|
|
- Push Notifications *(iOS only)*
|
|
|
- Background Refresh *(iOS only)*
|
|
|
+- Speech Recognition *(iOS only)*
|
|
|
|
|
|
|
|
|
| Version | React Native Support |
|
|
|
@@ -56,7 +57,7 @@ const Permissions = require('react-native-permissions');
|
|
|
Permissions.checkMultiplePermissions(['camera', 'photo'])
|
|
|
.then(response => {
|
|
|
//response is an object mapping type to permission
|
|
|
- this.setState({
|
|
|
+ this.setState({
|
|
|
cameraPermission: response.camera,
|
|
|
photoPermission: response.photo,
|
|
|
})
|
|
|
@@ -64,7 +65,7 @@ const Permissions = require('react-native-permissions');
|
|
|
}
|
|
|
|
|
|
// this is a common pattern when asking for permissions.
|
|
|
- // iOS only gives you once chance to show the permission dialog,
|
|
|
+ // iOS only gives you once chance to show the permission dialog,
|
|
|
// after which the user needs to manually enable them from settings.
|
|
|
// the idea here is to explain why we need access and determine if
|
|
|
// the user will say no, so that we don't blow our one chance.
|
|
|
@@ -75,7 +76,7 @@ const Permissions = require('react-native-permissions');
|
|
|
'We need access so you can set your profile pic',
|
|
|
[
|
|
|
{text: 'No way', onPress: () => console.log('permission denied'), style: 'cancel'},
|
|
|
- this.state.photoPermission == 'undetermined'?
|
|
|
+ this.state.photoPermission == 'undetermined'?
|
|
|
{text: 'OK', onPress: this._requestPermission.bind(this)}
|
|
|
: {text: 'Open Settings', onPress: Permissions.openSettings}
|
|
|
]
|
|
|
@@ -110,6 +111,7 @@ Promises resolve into one of these statuses
|
|
|
|`reminder`| ✔️ | ❌ |
|
|
|
|`notification`| ✔️ | ❌ |
|
|
|
|`backgroundRefresh`| ✔️ | ❌ |
|
|
|
+|`speechRecognition`| ✔️ | ❌ |
|
|
|
|`storage`| ❌️ | ✔ |
|
|
|
|
|
|
###Methods
|
|
|
@@ -163,14 +165,15 @@ All required permissions also need to be included in the Manifest before they ca
|
|
|
|
|
|
Permissions are automatically accepted for targetSdkVersion < 23 but you can still use `getPermissionStatus` to check if the user has disabled them from Settings.
|
|
|
|
|
|
-Here's a map of types to Android system permissions names:
|
|
|
-`location` -> `android.permission.ACCESS_FINE_LOCATION`
|
|
|
-`camera` -> `android.permission.CAMERA`
|
|
|
-`microphone` -> `android.permission.RECORD_AUDIO`
|
|
|
-`photo` -> `android.permission.READ_EXTERNAL_STORAGE`
|
|
|
-`storage` -> `android.permission.READ_EXTERNAL_STORAGE`
|
|
|
-`contacts` -> `android.permission.READ_CONTACTS`
|
|
|
-`event` -> `android.permission.READ_CALENDAR`
|
|
|
+Here's a map of types to Android system permissions names:
|
|
|
+`location` -> `android.permission.ACCESS_FINE_LOCATION`
|
|
|
+`camera` -> `android.permission.CAMERA`
|
|
|
+`microphone` -> `android.permission.RECORD_AUDIO`
|
|
|
+`photo` -> `android.permission.READ_EXTERNAL_STORAGE`
|
|
|
+`storage` -> `android.permission.READ_EXTERNAL_STORAGE`
|
|
|
+`contacts` -> `android.permission.READ_CONTACTS`
|
|
|
+`event` -> `android.permission.READ_CALENDAR`
|
|
|
+
|
|
|
|
|
|
You can request write access to any of these types by also including the appropriate write permission in the Manifest. Read more here: https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous
|
|
|
|
|
|
@@ -181,7 +184,7 @@ npm install --save react-native-permissions
|
|
|
rnpm link
|
|
|
````
|
|
|
|
|
|
-###Or manualy linking
|
|
|
+###Or manualy linking
|
|
|
|
|
|
####iOS
|
|
|
* Run open node_modules/react-native-permissions
|
|
|
@@ -233,10 +236,10 @@ public class MainApplication extends Application implements ReactApplication {
|
|
|
##Troubleshooting
|
|
|
|
|
|
#### Q: Android - `undefined is not a object (evaluating 'RNPermissions.requestPermissions')`
|
|
|
-A: `rnpm` may not have linked correctly. Follow the manual linking steps and make sure the library is linked
|
|
|
+A: `rnpm` may not have linked correctly. Follow the manual linking steps and make sure the library is linked
|
|
|
|
|
|
#### Q: iOS - app crashes as soon as I request permission
|
|
|
A: starting with xcode 8, you need to add permission descriptions. see iOS notes for more details. Thanks to @jesperlndk for discovering this.
|
|
|
|
|
|
#### Q: iOS - app crashes when I change permissions from settings
|
|
|
-A: This is normal. iOS restarts your app when your privacy settings change. Just google "ios crash permission change"
|
|
|
+A: This is normal. iOS restarts your app when your privacy settings change. Just google "ios crash permission change"
|