Skip to content

Commit f0058b1

Browse files
author
Yonah Forst
committed
update readme
1 parent 306e692 commit f0058b1

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ The current supported permissions are:
2222
| 0.2.5 | 0.33.0 - 0.39.0 |
2323
*Complies with [react-native-version-support-table](https://github.com/dangnelson/react-native-version-support-table)*
2424

25+
### Breaking changes in version 1.0.0
26+
- Now using React Native's own JS PermissionsAndroid library on Android, which is great because now we no longer have to do any additional linking (on Android)
27+
- Updated API to be closer to RN's PermissionsAndroid
28+
- Removed `openSettings()` support on Android (to stay linking-free). There are several NPM modules available for this
29+
- `restricted` status now supported on Android, although it means something different than iOS
30+
2531
## General Usage
2632
```
2733
npm install --save react-native-permissions
@@ -36,7 +42,7 @@ const Permissions = require('react-native-permissions');
3642
//...
3743
//check the status of a single permission
3844
componentDidMount() {
39-
Permissions.getPermissionStatus('photo')
45+
Permissions.check('photo')
4046
.then(response => {
4147
//response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
4248
this.setState({ photoPermission: response })
@@ -45,7 +51,7 @@ const Permissions = require('react-native-permissions');
4551

4652
//request permission to access photos
4753
_requestPermission() {
48-
Permissions.requestPermission('photo')
54+
Permissions.request('photo')
4955
.then(response => {
5056
//returns once the user has chosen to 'allow' or to 'not allow' access
5157
//response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
@@ -55,7 +61,7 @@ const Permissions = require('react-native-permissions');
5561

5662
//check the status of multiple permissions
5763
_checkCameraAndPhotos() {
58-
Permissions.checkMultiplePermissions(['camera', 'photo'])
64+
Permissions.check(['camera', 'photo'])
5965
.then(response => {
6066
//response is an object mapping type to permission
6167
this.setState({
@@ -118,18 +124,18 @@ Promises resolve into one of these statuses
118124
### Methods
119125
| Method Name | Arguments | Notes
120126
|---|---|---|
121-
| `check` | `type` | - Returns a promise with the permission status. See iOS Notes for special cases |
122-
| `request` | `type` | - Accepts any permission type except `backgroundRefresh`. If the current status is `undetermined`, shows the permission dialog and returns a promise with the resulting status. Otherwise, immediately return a promise with the current status. See iOS Notes for special cases|
123-
| `checkMultiple` | `[types]` | - Accepts an array of permission types and returns a promise with an object mapping permission types to statuses |
124-
| `getTypes` | *none* | - Returns an array of valid permission types |
125-
| `openSettings` | *none* | - *(iOS only - 8.0 and later)* Switches the user to the settings page of your app |
126-
| `canOpenSettings` | *none* | - *(iOS only)* Returns a boolean indicating if the device supports switching to the settings page |
127+
| `check()` | `type` | - Returns a promise with the permission status. See iOS Notes for special cases |
128+
| `request()` | `type` | - Accepts any permission type except `backgroundRefresh`. If the current status is `undetermined`, shows the permission dialog and returns a promise with the resulting status. Otherwise, immediately return a promise with the current status. See iOS Notes for special cases|
129+
| `checkMultiple()` | `[types]` | - Accepts an array of permission types and returns a promise with an object mapping permission types to statuses |
130+
| `getTypes()` | *none* | - Returns an array of valid permission types |
131+
| `openSettings()` | *none* | - *(iOS only - 8.0 and later)* Switches the user to the settings page of your app |
132+
| `canOpenSettings()` | *none* | - *(iOS only)* Returns a boolean indicating if the device supports switching to the settings page |
127133

128134
### iOS Notes
129135
- Permission type `bluetooth` represents the status of the `CBPeripheralManager`. Don't use this if only need `CBCentralManager`
130-
- Permission type `location` accepts a second parameter for `requestPermission` and `getPermissionStatus`; the second parameter is a string, either `always` or `whenInUse`(default).
136+
- Permission type `location` accepts a second parameter for `request()` and `check()`; the second parameter is a string, either `always` or `whenInUse`(default).
131137

132-
- Permission type `notification` accepts a second parameter for `requestPermission`. The second parameter is an array with the desired alert types. Any combination of `alert`, `badge` and `sound` (default requests all three)
138+
- 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)
133139

134140
```js
135141
///example
@@ -163,9 +169,9 @@ Requires RN >= 0.29.0
163169

164170
Uses RN's own `PermissionsAndroid` JS api (http://facebook.github.io/react-native/releases/0.45/docs/permissionsandroid.html)
165171

166-
All required permissions also need to be included in the Manifest before they can be requested. Otherwise `requestPermission` will immediately return `denied`.
172+
All required permissions also need to be included in the Manifest before they can be requested. Otherwise `request()` will immediately return `denied`.
167173

168-
Permissions are automatically accepted for targetSdkVersion < 23 but you can still use `getPermissionStatus` to check if the user has disabled them from Settings.
174+
Permissions are automatically accepted for targetSdkVersion < 23 but you can still use `check()` to check if the user has disabled them from Settings.
169175

170176
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
171177

@@ -204,6 +210,10 @@ So before submitting your app to the `AppStore`, make sure that in your `Info.pl
204210
<string>Some description</string>
205211
<key>NSPhotoLibraryUsageDescription</key>
206212
<string>Some description</string>
213+
<key>NSPhotoLibraryUsageDescription</key>
214+
<string>Some description</string>
215+
<key>NSSpeechRecognitionUsageDescription</key>
216+
<string>Some description</string>
207217
208218
```
209219

0 commit comments

Comments
 (0)