|
|
|
|
12
|
- Bluetooth *(iOS only)*
|
12
|
- Bluetooth *(iOS only)*
|
13
|
- Push Notifications *(iOS only)*
|
13
|
- Push Notifications *(iOS only)*
|
14
|
- Background Refresh *(iOS only)*
|
14
|
- Background Refresh *(iOS only)*
|
|
|
15
|
+- Speech Recognition *(iOS only)*
|
15
|
|
16
|
|
16
|
|
17
|
|
17
|
###New in version 0.2.X
|
18
|
###New in version 0.2.X
|
|
|
|
|
51
|
|
52
|
|
52
|
//check the status of multiple permissions
|
53
|
//check the status of multiple permissions
|
53
|
_checkCameraAndPhotos() {
|
54
|
_checkCameraAndPhotos() {
|
54
|
- Permissions.checkMultiplePermissions(['camera', 'photo'])
|
|
|
|
|
55
|
+ Permissions.checkMultiplePermissions(['camera', 'photo', 'speechRecognition'])
|
55
|
.then(response => {
|
56
|
.then(response => {
|
56
|
//response is an object mapping type to permission
|
57
|
//response is an object mapping type to permission
|
57
|
- this.setState({
|
|
|
|
|
58
|
+ this.setState({
|
58
|
cameraPermission: response.camera,
|
59
|
cameraPermission: response.camera,
|
59
|
photoPermission: response.photo,
|
60
|
photoPermission: response.photo,
|
60
|
})
|
61
|
})
|
|
|
|
|
62
|
}
|
63
|
}
|
63
|
|
64
|
|
64
|
// this is a common pattern when asking for permissions.
|
65
|
// this is a common pattern when asking for permissions.
|
65
|
- // iOS only gives you once chance to show the permission dialog,
|
|
|
|
|
66
|
+ // iOS only gives you once chance to show the permission dialog,
|
66
|
// after which the user needs to manually enable them from settings.
|
67
|
// after which the user needs to manually enable them from settings.
|
67
|
// the idea here is to explain why we need access and determine if
|
68
|
// the idea here is to explain why we need access and determine if
|
68
|
// the user will say no, so that we don't blow our one chance.
|
69
|
// the user will say no, so that we don't blow our one chance.
|
|
|
|
|
73
|
'We need access so you can set your profile pic',
|
74
|
'We need access so you can set your profile pic',
|
74
|
[
|
75
|
[
|
75
|
{text: 'No way', onPress: () => console.log('permission denied'), style: 'cancel'},
|
76
|
{text: 'No way', onPress: () => console.log('permission denied'), style: 'cancel'},
|
76
|
- this.state.photoPermission == 'undetermined'?
|
|
|
|
|
77
|
+ this.state.photoPermission == 'undetermined'?
|
77
|
{text: 'OK', onPress: this._requestPermission.bind(this)}
|
78
|
{text: 'OK', onPress: this._requestPermission.bind(this)}
|
78
|
: {text: 'Open Settings', onPress: Permissions.openSettings}
|
79
|
: {text: 'Open Settings', onPress: Permissions.openSettings}
|
79
|
]
|
80
|
]
|
|
|
|
|
108
|
|`reminder`| ✔️ | ❌ |
|
109
|
|`reminder`| ✔️ | ❌ |
|
109
|
|`notification`| ✔️ | ❌ |
|
110
|
|`notification`| ✔️ | ❌ |
|
110
|
|`backgroundRefresh`| ✔️ | ❌ |
|
111
|
|`backgroundRefresh`| ✔️ | ❌ |
|
|
|
112
|
+|`speechRecognition`| ✔️ | ❌ |
|
111
|
|
113
|
|
112
|
###Methods
|
114
|
###Methods
|
113
|
| Method Name | Arguments | Notes
|
115
|
| Method Name | Arguments | Notes
|
|
|
|
|
152
|
|
154
|
|
153
|
Permissions are automatically accepted for targetSdkVersion < 23 but you can still use `getPermissionStatus` to check if the user has disabled them from Settings.
|
155
|
Permissions are automatically accepted for targetSdkVersion < 23 but you can still use `getPermissionStatus` to check if the user has disabled them from Settings.
|
154
|
|
156
|
|
155
|
-Here's a map of types to Android system permissions names:
|
|
|
156
|
-`location` -> `android.permission.ACCESS_FINE_LOCATION`
|
|
|
157
|
-`camera` -> `android.permission.CAMERA`
|
|
|
158
|
-`microphone` -> `android.permission.RECORD_AUDIO`
|
|
|
159
|
-`photo` -> `android.permission.READ_EXTERNAL_STORAGE`
|
|
|
160
|
-`contacts` -> `android.permission.READ_CONTACTS`
|
|
|
161
|
-`event` -> `android.permission.READ_CALENDAR`
|
|
|
|
|
157
|
+Here's a map of types to Android system permissions names:
|
|
|
158
|
+`location` -> `android.permission.ACCESS_FINE_LOCATION`
|
|
|
159
|
+`camera` -> `android.permission.CAMERA`
|
|
|
160
|
+`microphone` -> `android.permission.RECORD_AUDIO`
|
|
|
161
|
+`photo` -> `android.permission.READ_EXTERNAL_STORAGE`
|
|
|
162
|
+`contacts` -> `android.permission.READ_CONTACTS`
|
|
|
163
|
+`event` -> `android.permission.READ_CALENDAR`
|
162
|
|
164
|
|
163
|
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
|
165
|
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
|
164
|
|
166
|
|
|
|
|
|
169
|
rnpm link
|
171
|
rnpm link
|
170
|
````
|
172
|
````
|
171
|
|
173
|
|
172
|
-###Or manualy linking
|
|
|
|
|
174
|
+###Or manualy linking
|
173
|
|
175
|
|
174
|
####iOS
|
176
|
####iOS
|
175
|
* Run open node_modules/react-native-permissions
|
177
|
* Run open node_modules/react-native-permissions
|
|
|
|
|
221
|
##Troubleshooting
|
223
|
##Troubleshooting
|
222
|
|
224
|
|
223
|
#### Q: Android - `undefined is not a object (evaluating 'RNPermissions.requestPermissions')`
|
225
|
#### Q: Android - `undefined is not a object (evaluating 'RNPermissions.requestPermissions')`
|
224
|
-A: `rnpm` may not have linked correctly. Follow the manual linking steps and make sure the library is linked
|
|
|
|
|
226
|
+A: `rnpm` may not have linked correctly. Follow the manual linking steps and make sure the library is linked
|
225
|
|
227
|
|
226
|
#### Q: iOS - app crashes as soon as I request permission
|
228
|
#### Q: iOS - app crashes as soon as I request permission
|
227
|
A: starting with xcode 8, you need to add permission descriptions. see iOS notes for more details. Thanks to @jesperlndk for discovering this.
|
229
|
A: starting with xcode 8, you need to add permission descriptions. see iOS notes for more details. Thanks to @jesperlndk for discovering this.
|