You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_📌 Don't forget to add permissions to `AndroidManifest.xml` for android and
40
-
`Info.plist` for iOS (Xcode >= 8). See [iOS Notes](#ios-notes) or [Android Notes](#android-notes) for more details._
25
+
_⚠️ To install `@react-native-community/async-storage`, please refers to the [package documentation](https://github.com/react-native-community/async-storage)._
26
+
27
+
_📌 Don't forget to add permissions to `AndroidManifest.xml` for android and `Info.plist` for iOS (Xcode >= 8). See [iOS Notes](#ios-notes) or [Android Notes](#android-notes) for more details._
41
28
42
29
### Additional iOS setup
43
30
44
31
#### Using cocoaPods
45
32
46
-
Update the following line with your path to `node_modules/` and add it to your
47
-
podfile:
33
+
Update the following line with your path to `node_modules/` and add it to your podfile:
48
34
49
35
```ruby
50
36
pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'
@@ -58,10 +44,8 @@ react-native link react-native-permissions
58
44
59
45
#### Using manual linking
60
46
61
-
1. In the XCode's "Project navigator", right click on your project's Libraries
62
-
folder ➜ `Add Files to <...>`
63
-
2. Go to `node_modules` ➜ `react-native-permissions` ➜ select
64
-
`ReactNativePermissions.xcodeproj`
47
+
1. In the XCode's "Project navigator", right click on your project's Libraries folder ➜ `Add Files to <…>`
48
+
2. Go to `node_modules` ➜ `react-native-permissions` ➜ select `ReactNativePermissions.xcodeproj`
65
49
3. Add `libReactNativePermissions.a` to `Build Phases` -> `Link Binary With Libraries`
66
50
67
51
## Using
@@ -71,10 +55,10 @@ import Permissions from 'react-native-permissions';
71
55
// OR const Permissions = require('react-native-permissions').default
72
56
// if you use CommonJS module system
73
57
74
-
//...
58
+
// …
75
59
76
60
exportdefaultclassextendsReact.Component {
77
-
//...
61
+
// …
78
62
79
63
// Check the status of a single permission
80
64
componentDidMount() {
@@ -127,7 +111,7 @@ export default class extends React.Component {
127
111
);
128
112
}
129
113
130
-
//...
114
+
// …
131
115
}
132
116
```
133
117
@@ -183,14 +167,9 @@ The current supported permissions are:
183
167
184
168
### iOS Notes
185
169
186
-
- Permission type `bluetooth` represents the status of the
187
-
`CBPeripheralManager`. Don't use this if you only need `CBCentralManager`.
188
-
- Permission type `location` accepts a second parameter for `request()` and
189
-
`check()`; the second parameter is a string, either `always` or `whenInUse`
190
-
(default).
191
-
- Permission type `notification` accepts a second parameter for `request()`. The
192
-
second parameter is an array with the desired alert types. Any combination of
193
-
`alert`, `badge` and `sound` (default requests all three).
170
+
- Permission type `bluetooth` represents the status of the `CBPeripheralManager`. Don't use this if you only need `CBCentralManager`.
171
+
- Permission type `location` accepts a second parameter for `request()` and `check()`; the second parameter is a string, either `always` or `whenInUse` (default).
172
+
- Permission type `notification` accepts a second parameter for `request()`. The second parameter is an array with the desired alert types. Any combination of `alert`, `badge` and `sound` (default requests all three).
194
173
- If you are not requesting mediaLibrary then you can remove MediaPlayer.framework from the xcode project.
- You cannot request microphone permissions on the simulator.
214
-
- With Xcode 8, you now need to add usage descriptions for each permission you
215
-
will request. Open Xcode ➜ `Info.plist` ➜ Add a key (starting with "Privacy -
216
-
...") with your kit specific permission.
193
+
- 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.
217
194
218
195
Example: If you need Contacts permission you have to add the key `Privacy - Contacts Usage Description`.
If you need to submit your application to the AppStore, you need to add to your
225
-
`Info.plist` all `*UsageDescription` keys with a string value explaining to the
226
-
user how the app uses this data. **Even if you don't use them**.
201
+
If you need to submit your application to the AppStore, you need to add to your `Info.plist` all `*UsageDescription` keys with a string value explaining to the user how the app uses this data. **Even if you don't use them**.
227
202
228
-
So before submitting your app to the App Store, make sure that in your
229
-
`Info.plist` you have the following keys:
203
+
So before submitting your app to the App Store, make sure that in your `Info.plist` you have the following keys:
230
204
231
205
```xml
232
206
<key>NSBluetoothPeripheralUsageDescription</key>
@@ -249,28 +223,19 @@ So before submitting your app to the App Store, make sure that in your
249
223
<string>Some description</string>
250
224
```
251
225
252
-
This is required because during the phase of processing in the App Store
253
-
submission, the system detects that you app contains code to request the
254
-
permission `X` but don't have the `UsageDescription` key and then it rejects the
255
-
build.
226
+
This is required because during the phase of processing in the App Store submission, the system detects that you app contains code to request the permission `X` but don't have the `UsageDescription` key and then it rejects the build.
256
227
257
-
> Please note that it will only be shown to the users the usage descriptions of
258
-
> the permissions you really require in your app.
228
+
> Please note that it will only be shown to the users the usage descriptions of the permissions you really require in your app.
259
229
260
230
You can find more information about this issue in #46.
- Uses React Native's own [`PermissionsAndroid` JS API](http://facebook.github.io/react-native/docs/permissionsandroid.html).
235
+
- All required permissions also need to be included in the `AndroidManifest.xml` file before they can be requested. Otherwise `request()` will immediately return `denied`.
236
+
- You can request write access to any of these types by also including the appropriate write permission in the `AndroidManifest.xml` file. [here](https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous). _e.g._`<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>`
272
237
273
-
Read more [here](https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous).
238
+
Read more [here](https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous).
274
239
275
240
- The optional rationale argument will show a dialog prompt.
- Permissions are automatically accepted for **targetSdkVersion < 23** but you
292
-
can still use `check()` to check if the user has disabled them from Settings.
293
-
294
-
You might need to elevate the **targetSdkVersion** version in your
295
-
`build.gradle`:
296
-
297
-
```groovy
298
-
android {
299
-
compileSdkVersion 23 // ← set at least 23
300
-
buildToolsVersion "23.0.1" // ← set at least 23.0.0
301
-
302
-
defaultConfig {
303
-
minSdkVersion 16
304
-
targetSdkVersion 23 // ← set at least 23
305
-
// ...
306
-
```
256
+
- Permissions are automatically accepted for **targetSdkVersion < 23** but you can still use `check()` to check if the user has disabled them from Settings.
307
257
308
258
## Troubleshooting
309
259
310
260
#### Q: iOS - App crashes as soon as I request permission
311
261
312
-
> A: Starting with Xcode 8, you need to add permission descriptions. See iOS
313
-
> notes for more details. Thanks to [@jesperlndk](https://github.com/jesperlndk)
314
-
> for discovering this.
262
+
> 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.
315
263
316
264
#### Q: iOS - App crashes when I change permission from settings
317
265
318
-
> A: This is normal. iOS restarts your app when your privacy settings change.
319
-
> Just google "iOS crash permission change".
266
+
> A: This is normal. iOS restarts your app when your privacy settings change. Just google "iOS crash permission change".
0 commit comments