Skip to content

Commit 1d43489

Browse files
committed
Update README
1 parent 98e0d77 commit 1d43489

File tree

1 file changed

+28
-81
lines changed

1 file changed

+28
-81
lines changed

README.md

Lines changed: 28 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,29 @@
88

99
Request user permissions from React Native, iOS + Android
1010

11-
### 2.0.0 is on it's way! A bit of help is needed [here](https://github.com/yonahforst/react-native-permissions/pull/291)!
11+
### 2.0.0 is on it's way! A bit of help is needed [here](https://github.com/react-native-community/react-native-permissions/pull/291)!
1212

1313
| Version | React Native Support |
1414
| ------- | -------------------- |
15-
| 1.1.1 | 0.40 - 0.52 |
16-
| 0.2.5 | 0.33 - 0.39 |
17-
18-
_Complies with
19-
[react-native-version-support-table](https://github.com/dangnelson/react-native-version-support-table)_
20-
21-
## ⚠️ Breaking changes in version 1.0.0
22-
23-
- Now using React Native's own JS `PermissionsAndroid` module on Android, which
24-
is great because we no longer have to do any additional linking on Android
25-
- Updated API to be closer to React Native's `PermissionsAndroid`
26-
- Removed `openSettings()` support on Android (to stay linking-free). There are
27-
several NPM modules available for this
28-
- `restricted` status now supported on Android, although it means something
29-
different than iOS
15+
| 1.2.0+ | 0.52.0+ |
3016

3117
## Setup
3218

3319
```sh
34-
npm install --save react-native-permissions
20+
npm install --save react-native-permissions @react-native-community/async-storage
3521
# --- or ---
36-
yarn add react-native-permissions
22+
yarn add react-native-permissions @react-native-community/async-storage
3723
```
3824

39-
_📌 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._
4128

4229
### Additional iOS setup
4330

4431
#### Using cocoaPods
4532

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:
4834

4935
```ruby
5036
pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'
@@ -58,10 +44,8 @@ react-native link react-native-permissions
5844

5945
#### Using manual linking
6046

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`
6549
3. Add `libReactNativePermissions.a` to `Build Phases` -> `Link Binary With Libraries`
6650

6751
## Using
@@ -71,10 +55,10 @@ import Permissions from 'react-native-permissions';
7155
// OR const Permissions = require('react-native-permissions').default
7256
// if you use CommonJS module system
7357

74-
//...
58+
//
7559

7660
export default class extends React.Component {
77-
//...
61+
//
7862

7963
// Check the status of a single permission
8064
componentDidMount() {
@@ -127,7 +111,7 @@ export default class extends React.Component {
127111
);
128112
}
129113

130-
//...
114+
//
131115
}
132116
```
133117

@@ -183,14 +167,9 @@ The current supported permissions are:
183167

184168
### iOS Notes
185169

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).
194173
- If you are not requesting mediaLibrary then you can remove MediaPlayer.framework from the xcode project.
195174

196175
```js
@@ -211,22 +190,17 @@ Permissions.request('notification', {type: ['alert', 'badge']}).then(
211190
```
212191

213192
- 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.
217194

218195
Example: If you need Contacts permission you have to add the key `Privacy - Contacts Usage Description`.
219196

220197
<img width="338" alt="3cde3b44-7ffd-11e6-918b-63888e33f983" src="https://cloud.githubusercontent.com/assets/1440796/18713019/271be540-8011-11e6-87fb-c3828c172dfc.png">
221198

222199
#### App Store submission disclaimer
223200

224-
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**.
227202

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:
230204

231205
```xml
232206
<key>NSBluetoothPeripheralUsageDescription</key>
@@ -249,28 +223,19 @@ So before submitting your app to the App Store, make sure that in your
249223
<string>Some description</string>
250224
```
251225

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.
256227

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.
259229
260230
You can find more information about this issue in #46.
261231

262232
### Android Notes
263233

264-
- Uses React Native's own
265-
[`PermissionsAndroid` JS API](http://facebook.github.io/react-native/docs/permissionsandroid.html).
266-
- All required permissions also need to be included in the `AndroidManifest.xml`
267-
file before they can be requested. Otherwise `request()` will immediately
268-
return `denied`.
269-
- You can request write access to any of these types by also including the
270-
appropriate write permission in the `AndroidManifest.xml` file.
271-
[here](https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous). _e.g._ `<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>`
234+
- 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"/>`
272237

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).
274239

275240
- The optional rationale argument will show a dialog prompt.
276241

@@ -288,32 +253,14 @@ Permissions.request('camera', {
288253
});
289254
```
290255

291-
- 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.
307257

308258
## Troubleshooting
309259

310260
#### Q: iOS - App crashes as soon as I request permission
311261

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.
315263
316264
#### Q: iOS - App crashes when I change permission from settings
317265

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

Comments
 (0)