|
@@ -11,7 +11,7 @@ Request user permissions from React Native, iOS + Android
|
11
|
11
|
|
12
|
12
|
## ⚠️ Breaking changes in version 1.0.0
|
13
|
13
|
- Now using React Native's own JS `PermissionsAndroid` module on Android, which is great because we no longer have to do any additional linking on Android
|
14
|
|
-- Updated API to be closer to RN's PermissionsAndroid
|
|
14
|
+- Updated API to be closer to React Native's PermissionsAndroid
|
15
|
15
|
- Removed `openSettings()` support on Android (to stay linking-free). There are several NPM modules available for this
|
16
|
16
|
- `restricted` status now supported on Android, although it means something different than iOS
|
17
|
17
|
|
|
@@ -19,15 +19,11 @@ Request user permissions from React Native, iOS + Android
|
19
|
19
|
|
20
|
20
|
```sh
|
21
|
21
|
npm install --save react-native-permissions
|
22
|
|
-```
|
23
|
|
-
|
24
|
|
-**OR**
|
25
|
|
-
|
26
|
|
-```sh
|
|
22
|
+--- or ---
|
27
|
23
|
yarn add react-native-permissions
|
28
|
24
|
```
|
29
|
25
|
|
30
|
|
-*📌 Don't forget to add permissions to `AndroidManifest.xml` for android and `Info.plist` for iOS (Xcode >=8). See notes below for more details.*
|
|
26
|
+📌 Don't forget to add permissions to `AndroidManifest.xml` for android and `Info.plist` for iOS (Xcode >=8). See notes below for more details.
|
31
|
27
|
|
32
|
28
|
### Additional iOS setup
|
33
|
29
|
|
|
@@ -122,10 +118,10 @@ Promises resolve into one of these statuses:
|
122
|
118
|
|
123
|
119
|
| Return value | Notes|
|
124
|
120
|
|---|---|
|
125
|
|
-|`authorized`| user has authorized this permission |
|
126
|
|
-|`denied`| user has denied this permission at least once. On iOS this means that the user will not be prompted again. Android users can be promted multiple times until they select 'Never ask me again'|
|
127
|
|
-|`restricted`| **iOS** - this means user is not able to grant this permission, either because it's not supported by the device or because it has been blocked by parental controls. **Android** - this means that the user has selected 'Never ask me again' while denying permission |
|
128
|
|
-|`undetermined`| user has not yet been prompted with a permission dialog |
|
|
121
|
+|`authorized`| User has authorized this permission |
|
|
122
|
+|`denied`| User has denied this permission at least once. On iOS this means that the user will not be prompted again. Android users can be promted multiple times until they select 'Never ask me again'|
|
|
123
|
+|`restricted`| **iOS only** - this means user is not able to grant this permission, either because it's not supported by the device or because it has been blocked by parental controls. **Android** - this means that the user has selected 'Never ask me again' while denying permission |
|
|
124
|
+|`undetermined`| User has not yet been prompted with a permission dialog |
|
129
|
125
|
|
130
|
126
|
### Supported permissions types
|
131
|
127
|
|
|
@@ -187,7 +183,7 @@ Permissions.request("notification", ["alert", "badge"]).then(response => {
|
187
|
183
|
- With Xcode 8, you now need to add usage descriptions for each permission you will request. Open Xcode ➜ `Info.plist` ➜ Add a key (starting with "Privacy - ...") with your kit specific permission.
|
188
|
184
|
|
189
|
185
|
Example:
|
190
|
|
-If you need Contacts permission you have to add the key "Privacy - Contacts Usage Description".
|
|
186
|
+If you need Contacts permission you have to add the key `Privacy - Contacts Usage Description`.
|
191
|
187
|
|
192
|
188
|
<img width="338" alt="3cde3b44-7ffd-11e6-918b-63888e33f983" src="https://cloud.githubusercontent.com/assets/1440796/18713019/271be540-8011-11e6-87fb-c3828c172dfc.png">
|
193
|
189
|
|
|
@@ -220,18 +216,15 @@ You can find more informations about this issue in #46.
|
220
|
216
|
|
221
|
217
|
### Android Notes
|
222
|
218
|
|
223
|
|
-Uses RN's own `PermissionsAndroid` JS api (http://facebook.github.io/react-native/releases/0.45/docs/permissionsandroid.html)
|
224
|
|
-
|
225
|
|
-All required permissions also need to be included in the `AndroidManifest.xml` file before they can be requested. Otherwise `request()` will immediately return `denied`.
|
226
|
|
-
|
227
|
|
-Permissions are automatically accepted for **targetSdkVersion < 23** but you can still use `check()` to check if the user has disabled them from Settings.
|
228
|
|
-
|
229
|
|
-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
|
|
219
|
+- Uses React Native's own [`PermissionsAndroid` JS API](http://facebook.github.io/react-native/docs/permissionsandroid.html).
|
|
220
|
+- All required permissions also need to be included in the `AndroidManifest.xml` file before they can be requested. Otherwise `request()` will immediately return `denied`.
|
|
221
|
+- Permissions are automatically accepted for **targetSdkVersion < 23** but you can still use `check()` to check if the user has disabled them from Settings.
|
|
222
|
+- You can request write access to any of these types by also including the appropriate write permission in the `AndroidManifest.xml` file. Read more [here](https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous).
|
230
|
223
|
|
231
|
224
|
## Troubleshooting
|
232
|
225
|
|
233
|
226
|
#### Q: iOS - App crashes as soon as I request permission
|
234
|
|
-A: starting with Xcode 8, you need to add permission descriptions. See iOS notes for more details. Thanks to [@jesperlndk](https://github.com/jesperlndk) for discovering this.
|
|
227
|
+> A: Starting with Xcode 8, you need to add permission descriptions. See iOS notes for more details. Thanks to [@jesperlndk](https://github.com/jesperlndk) for discovering this.
|
235
|
228
|
|
236
|
229
|
#### Q: iOS - App crashes when I change permission from settings
|
237
|
|
-A: This is normal. iOS restarts your app when your privacy settings change. Just google "iOS crash permission change"
|
|
230
|
+> A: This is normal. iOS restarts your app when your privacy settings change. Just google "iOS crash permission change"
|