|
@@ -12,6 +12,7 @@ The current supported permissions are:
|
12
|
12
|
- Bluetooth *(iOS only)*
|
13
|
13
|
- Push Notifications *(iOS only)*
|
14
|
14
|
- Background Refresh *(iOS only)*
|
|
15
|
+- Speech Recognition *(iOS only)*
|
15
|
16
|
|
16
|
17
|
|
17
|
18
|
| Version | React Native Support |
|
|
@@ -56,7 +57,7 @@ const Permissions = require('react-native-permissions');
|
56
|
57
|
Permissions.checkMultiplePermissions(['camera', 'photo'])
|
57
|
58
|
.then(response => {
|
58
|
59
|
//response is an object mapping type to permission
|
59
|
|
- this.setState({
|
|
60
|
+ this.setState({
|
60
|
61
|
cameraPermission: response.camera,
|
61
|
62
|
photoPermission: response.photo,
|
62
|
63
|
})
|
|
@@ -64,7 +65,7 @@ const Permissions = require('react-native-permissions');
|
64
|
65
|
}
|
65
|
66
|
|
66
|
67
|
// this is a common pattern when asking for permissions.
|
67
|
|
- // iOS only gives you once chance to show the permission dialog,
|
|
68
|
+ // iOS only gives you once chance to show the permission dialog,
|
68
|
69
|
// after which the user needs to manually enable them from settings.
|
69
|
70
|
// the idea here is to explain why we need access and determine if
|
70
|
71
|
// the user will say no, so that we don't blow our one chance.
|
|
@@ -75,7 +76,7 @@ const Permissions = require('react-native-permissions');
|
75
|
76
|
'We need access so you can set your profile pic',
|
76
|
77
|
[
|
77
|
78
|
{text: 'No way', onPress: () => console.log('permission denied'), style: 'cancel'},
|
78
|
|
- this.state.photoPermission == 'undetermined'?
|
|
79
|
+ this.state.photoPermission == 'undetermined'?
|
79
|
80
|
{text: 'OK', onPress: this._requestPermission.bind(this)}
|
80
|
81
|
: {text: 'Open Settings', onPress: Permissions.openSettings}
|
81
|
82
|
]
|
|
@@ -110,6 +111,7 @@ Promises resolve into one of these statuses
|
110
|
111
|
|`reminder`| ✔️ | ❌ |
|
111
|
112
|
|`notification`| ✔️ | ❌ |
|
112
|
113
|
|`backgroundRefresh`| ✔️ | ❌ |
|
|
114
|
+|`speechRecognition`| ✔️ | ❌ |
|
113
|
115
|
|`storage`| ❌️ | ✔ |
|
114
|
116
|
|
115
|
117
|
###Methods
|
|
@@ -163,14 +165,15 @@ All required permissions also need to be included in the Manifest before they ca
|
163
|
165
|
|
164
|
166
|
Permissions are automatically accepted for targetSdkVersion < 23 but you can still use `getPermissionStatus` to check if the user has disabled them from Settings.
|
165
|
167
|
|
166
|
|
-Here's a map of types to Android system permissions names:
|
167
|
|
-`location` -> `android.permission.ACCESS_FINE_LOCATION`
|
168
|
|
-`camera` -> `android.permission.CAMERA`
|
169
|
|
-`microphone` -> `android.permission.RECORD_AUDIO`
|
170
|
|
-`photo` -> `android.permission.READ_EXTERNAL_STORAGE`
|
171
|
|
-`storage` -> `android.permission.READ_EXTERNAL_STORAGE`
|
172
|
|
-`contacts` -> `android.permission.READ_CONTACTS`
|
173
|
|
-`event` -> `android.permission.READ_CALENDAR`
|
|
168
|
+Here's a map of types to Android system permissions names:
|
|
169
|
+`location` -> `android.permission.ACCESS_FINE_LOCATION`
|
|
170
|
+`camera` -> `android.permission.CAMERA`
|
|
171
|
+`microphone` -> `android.permission.RECORD_AUDIO`
|
|
172
|
+`photo` -> `android.permission.READ_EXTERNAL_STORAGE`
|
|
173
|
+`storage` -> `android.permission.READ_EXTERNAL_STORAGE`
|
|
174
|
+`contacts` -> `android.permission.READ_CONTACTS`
|
|
175
|
+`event` -> `android.permission.READ_CALENDAR`
|
|
176
|
+
|
174
|
177
|
|
175
|
178
|
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
|
176
|
179
|
|
|
@@ -181,7 +184,7 @@ npm install --save react-native-permissions
|
181
|
184
|
rnpm link
|
182
|
185
|
````
|
183
|
186
|
|
184
|
|
-###Or manualy linking
|
|
187
|
+###Or manualy linking
|
185
|
188
|
|
186
|
189
|
####iOS
|
187
|
190
|
* Run open node_modules/react-native-permissions
|
|
@@ -233,10 +236,10 @@ public class MainApplication extends Application implements ReactApplication {
|
233
|
236
|
##Troubleshooting
|
234
|
237
|
|
235
|
238
|
#### Q: Android - `undefined is not a object (evaluating 'RNPermissions.requestPermissions')`
|
236
|
|
-A: `rnpm` may not have linked correctly. Follow the manual linking steps and make sure the library is linked
|
|
239
|
+A: `rnpm` may not have linked correctly. Follow the manual linking steps and make sure the library is linked
|
237
|
240
|
|
238
|
241
|
#### Q: iOS - app crashes as soon as I request permission
|
239
|
242
|
A: starting with xcode 8, you need to add permission descriptions. see iOS notes for more details. Thanks to @jesperlndk for discovering this.
|
240
|
243
|
|
241
|
244
|
#### Q: iOS - app crashes when I change permissions from settings
|
242
|
|
-A: This is normal. iOS restarts your app when your privacy settings change. Just google "ios crash permission change"
|
|
245
|
+A: This is normal. iOS restarts your app when your privacy settings change. Just google "ios crash permission change"
|