|
@@ -21,7 +21,7 @@ The current supported permissions are:
|
21
|
21
|
| 0.2.5 | 0.33.0 - 0.39.0 |
|
22
|
22
|
*Complies with [react-native-version-support-table](https://github.com/dangnelson/react-native-version-support-table)*
|
23
|
23
|
|
24
|
|
-##General Usage
|
|
24
|
+## General Usage
|
25
|
25
|
```
|
26
|
26
|
npm install --save react-native-permissions
|
27
|
27
|
rnpm link
|
|
@@ -85,9 +85,9 @@ const Permissions = require('react-native-permissions');
|
85
|
85
|
//...
|
86
|
86
|
```
|
87
|
87
|
|
88
|
|
-##API
|
|
88
|
+## API
|
89
|
89
|
|
90
|
|
-###Permission statuses
|
|
90
|
+### Permission statuses
|
91
|
91
|
Promises resolve into one of these statuses
|
92
|
92
|
|
93
|
93
|
| Return value | Notes|
|
|
@@ -97,7 +97,7 @@ Promises resolve into one of these statuses
|
97
|
97
|
|`restricted`| *(iOS only)* 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. |
|
98
|
98
|
|`undetermined`| user has not yet been prompted with a permission dialog |
|
99
|
99
|
|
100
|
|
-###Supported permission types
|
|
100
|
+### Supported permission types
|
101
|
101
|
|
102
|
102
|
| Name | iOS | Android |
|
103
|
103
|
|---|---|---|
|
|
@@ -114,7 +114,7 @@ Promises resolve into one of these statuses
|
114
|
114
|
|`speechRecognition`| ✔️ | ❌ |
|
115
|
115
|
|`storage`| ❌️ | ✔ |
|
116
|
116
|
|
117
|
|
-###Methods
|
|
117
|
+### Methods
|
118
|
118
|
| Method Name | Arguments | Notes
|
119
|
119
|
|---|---|---|
|
120
|
120
|
| `getPermissionStatus` | `type` | - Returns a promise with the permission status. See iOS Notes for special cases |
|
|
@@ -124,7 +124,7 @@ Promises resolve into one of these statuses
|
124
|
124
|
| `openSettings` | *none* | - Switches the user to the settings page of your app (iOS 8.0 and later) |
|
125
|
125
|
| `canOpenSettings` | *none* | - Returns a boolean indicating if the device supports switching to the settings page |
|
126
|
126
|
|
127
|
|
-###iOS Notes
|
|
127
|
+### iOS Notes
|
128
|
128
|
Permission type `bluetooth` represents the status of the `CBPeripheralManager`. Don't use this if only need `CBCentralManager`
|
129
|
129
|
|
130
|
130
|
Permission type `location` accepts a second parameter for `requestPermission` and `getPermissionStatus`; the second parameter is a string, either `always` or `whenInUse`(default).
|
|
@@ -157,7 +157,7 @@ Example:
|
157
|
157
|
If you need Contacts permission you have to add the key "Privacy - Contacts Usage Description".
|
158
|
158
|
<img width="338" alt="3cde3b44-7ffd-11e6-918b-63888e33f983" src="https://cloud.githubusercontent.com/assets/1440796/18713019/271be540-8011-11e6-87fb-c3828c172dfc.png">
|
159
|
159
|
|
160
|
|
-###Android Notes
|
|
160
|
+### Android Notes
|
161
|
161
|
|
162
|
162
|
Requires RN >= 0.29.0
|
163
|
163
|
|
|
@@ -177,22 +177,22 @@ Here's a map of types to Android system permissions names:
|
177
|
177
|
|
178
|
178
|
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
|
179
|
179
|
|
180
|
|
-##Setup
|
|
180
|
+## Setup
|
181
|
181
|
|
182
|
182
|
````
|
183
|
183
|
npm install --save react-native-permissions
|
184
|
184
|
rnpm link
|
185
|
185
|
````
|
186
|
186
|
|
187
|
|
-###Or manualy linking
|
|
187
|
+### Or manualy linking
|
188
|
188
|
|
189
|
|
-####iOS
|
|
189
|
+#### iOS
|
190
|
190
|
* Run open node_modules/react-native-permissions
|
191
|
191
|
* Drag ReactNativePermissions.xcodeproj into the Libraries group of your app's Xcode project
|
192
|
192
|
* Add libReactNativePermissions.a to `Build Phases -> Link Binary With Libraries.
|
193
|
193
|
|
194
|
|
-####Android
|
195
|
|
-#####Step 1 - Update Gradle Settings
|
|
194
|
+#### Android
|
|
195
|
+##### Step 1 - Update Gradle Settings
|
196
|
196
|
|
197
|
197
|
```
|
198
|
198
|
// file: android/settings.gradle
|
|
@@ -201,7 +201,7 @@ rnpm link
|
201
|
201
|
include ':react-native-permissions'
|
202
|
202
|
project(':react-native-permissions').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-permissions/android')
|
203
|
203
|
```
|
204
|
|
-#####Step 2 - Update Gradle Build
|
|
204
|
+##### Step 2 - Update Gradle Build
|
205
|
205
|
|
206
|
206
|
```
|
207
|
207
|
// file: android/app/build.gradle
|
|
@@ -212,7 +212,7 @@ dependencies {
|
212
|
212
|
compile project(':react-native-permissions')
|
213
|
213
|
}
|
214
|
214
|
```
|
215
|
|
-#####Step 3 - Register React Package
|
|
215
|
+##### Step 3 - Register React Package
|
216
|
216
|
```
|
217
|
217
|
...
|
218
|
218
|
import com.joshblour.reactnativepermissions.ReactNativePermissionsPackage; // <--- import
|
|
@@ -233,7 +233,7 @@ public class MainApplication extends Application implements ReactApplication {
|
233
|
233
|
}
|
234
|
234
|
```
|
235
|
235
|
|
236
|
|
-##Troubleshooting
|
|
236
|
+## Troubleshooting
|
237
|
237
|
|
238
|
238
|
#### Q: Android - `undefined is not a object (evaluating 'RNPermissions.requestPermissions')`
|
239
|
239
|
A: `rnpm` may not have linked correctly. Follow the manual linking steps and make sure the library is linked
|