Browse Source

update readme

Yonah Forst 7 years ago
parent
commit
f0058b13b5
1 changed files with 23 additions and 13 deletions
  1. 23
    13
      README.md

+ 23
- 13
README.md View File

22
 | 0.2.5 | 0.33.0 - 0.39.0 |
22
 | 0.2.5 | 0.33.0 - 0.39.0 |
23
 *Complies with [react-native-version-support-table](https://github.com/dangnelson/react-native-version-support-table)*
23
 *Complies with [react-native-version-support-table](https://github.com/dangnelson/react-native-version-support-table)*
24
 
24
 
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
+
25
 ## General Usage
31
 ## General Usage
26
 ```
32
 ```
27
 npm install --save react-native-permissions
33
 npm install --save react-native-permissions
36
 //...
42
 //...
37
   //check the status of a single permission
43
   //check the status of a single permission
38
   componentDidMount() {
44
   componentDidMount() {
39
-    Permissions.getPermissionStatus('photo')
45
+    Permissions.check('photo')
40
       .then(response => {
46
       .then(response => {
41
         //response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
47
         //response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
42
         this.setState({ photoPermission: response })
48
         this.setState({ photoPermission: response })
45
 
51
 
46
   //request permission to access photos
52
   //request permission to access photos
47
   _requestPermission() {
53
   _requestPermission() {
48
-    Permissions.requestPermission('photo')
54
+    Permissions.request('photo')
49
       .then(response => {
55
       .then(response => {
50
         //returns once the user has chosen to 'allow' or to 'not allow' access
56
         //returns once the user has chosen to 'allow' or to 'not allow' access
51
         //response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
57
         //response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
55
 
61
 
56
   //check the status of multiple permissions
62
   //check the status of multiple permissions
57
   _checkCameraAndPhotos() {
63
   _checkCameraAndPhotos() {
58
-    Permissions.checkMultiplePermissions(['camera', 'photo'])
64
+    Permissions.check(['camera', 'photo'])
59
       .then(response => {
65
       .then(response => {
60
         //response is an object mapping type to permission
66
         //response is an object mapping type to permission
61
         this.setState({
67
         this.setState({
118
 ### Methods
124
 ### Methods
119
 | Method Name | Arguments | Notes
125
 | Method Name | Arguments | Notes
120
 |---|---|---|
126
 |---|---|---|
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 |
127
 
133
 
128
 ### iOS Notes
134
 ### iOS Notes
129
 - Permission type `bluetooth` represents the status of the `CBPeripheralManager`. Don't use this if only need `CBCentralManager`
135
 - 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).
131
 
137
 
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)
133
 
139
 
134
 ```js
140
 ```js
135
 ///example
141
 ///example
163
 
169
 
164
 Uses RN's own `PermissionsAndroid` JS api (http://facebook.github.io/react-native/releases/0.45/docs/permissionsandroid.html)
170
 Uses RN's own `PermissionsAndroid` JS api (http://facebook.github.io/react-native/releases/0.45/docs/permissionsandroid.html)
165
 
171
 
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`.
167
 
173
 
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.
169
 
175
 
170
 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
176
 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
171
 
177
 
204
 <string>Some description</string>
210
 <string>Some description</string>
205
 <key>NSPhotoLibraryUsageDescription</key>
211
 <key>NSPhotoLibraryUsageDescription</key>
206
 <string>Some description</string>
212
 <string>Some description</string>
213
+<key>NSPhotoLibraryUsageDescription</key>
214
+<string>Some description</string>
215
+<key>NSSpeechRecognitionUsageDescription</key>
216
+<string>Some description</string>
207
 
217
 
208
 ```
218
 ```
209
 
219