ソースを参照

Update README

Mathieu Acthernoene 5 年 前
コミット
1d43489557
共有1 個のファイルを変更した28 個の追加81 個の削除を含む
  1. 28
    81
      README.md

+ 28
- 81
README.md ファイルの表示

8
 
8
 
9
 Request user permissions from React Native, iOS + Android
9
 Request user permissions from React Native, iOS + Android
10
 
10
 
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)!
12
 
12
 
13
 | Version | React Native Support |
13
 | Version | React Native Support |
14
 | ------- | -------------------- |
14
 | ------- | -------------------- |
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+              |
30
 
16
 
31
 ## Setup
17
 ## Setup
32
 
18
 
33
 ```sh
19
 ```sh
34
-npm install --save react-native-permissions
20
+npm install --save react-native-permissions @react-native-community/async-storage
35
 # --- or ---
21
 # --- or ---
36
-yarn add react-native-permissions
22
+yarn add react-native-permissions @react-native-community/async-storage
37
 ```
23
 ```
38
 
24
 
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._
41
 
28
 
42
 ### Additional iOS setup
29
 ### Additional iOS setup
43
 
30
 
44
 #### Using cocoaPods
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
 ```ruby
35
 ```ruby
50
 pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'
36
 pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'
58
 
44
 
59
 #### Using manual linking
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
 3. Add `libReactNativePermissions.a` to `Build Phases` -> `Link Binary With Libraries`
49
 3. Add `libReactNativePermissions.a` to `Build Phases` -> `Link Binary With Libraries`
66
 
50
 
67
 ## Using
51
 ## Using
71
 // OR const Permissions = require('react-native-permissions').default
55
 // OR const Permissions = require('react-native-permissions').default
72
 // if you use CommonJS module system
56
 // if you use CommonJS module system
73
 
57
 
74
-//...
58
+//
75
 
59
 
76
 export default class extends React.Component {
60
 export default class extends React.Component {
77
-  //...
61
+  //
78
 
62
 
79
   // Check the status of a single permission
63
   // Check the status of a single permission
80
   componentDidMount() {
64
   componentDidMount() {
127
     );
111
     );
128
   }
112
   }
129
 
113
 
130
-  //...
114
+  //
131
 }
115
 }
132
 ```
116
 ```
133
 
117
 
183
 
167
 
184
 ### iOS Notes
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
 - If you are not requesting mediaLibrary then you can remove MediaPlayer.framework from the xcode project.
173
 - If you are not requesting mediaLibrary then you can remove MediaPlayer.framework from the xcode project.
195
 
174
 
196
 ```js
175
 ```js
211
 ```
190
 ```
212
 
191
 
213
 - You cannot request microphone permissions on the simulator.
192
 - 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
 Example: If you need Contacts permission you have to add the key `Privacy - Contacts Usage Description`.
195
 Example: If you need Contacts permission you have to add the key `Privacy - Contacts Usage Description`.
219
 
196
 
221
 
198
 
222
 #### App Store submission disclaimer
199
 #### App Store submission disclaimer
223
 
200
 
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**.
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
 ```xml
205
 ```xml
232
 <key>NSBluetoothPeripheralUsageDescription</key>
206
 <key>NSBluetoothPeripheralUsageDescription</key>
249
 <string>Some description</string>
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
 You can find more information about this issue in #46.
230
 You can find more information about this issue in #46.
261
 
231
 
262
 ### Android Notes
232
 ### Android Notes
263
 
233
 
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"/>`
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
 - The optional rationale argument will show a dialog prompt.
240
 - The optional rationale argument will show a dialog prompt.
276
 
241
 
288
 });
253
 });
289
 ```
254
 ```
290
 
255
 
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.
307
 
257
 
308
 ## Troubleshooting
258
 ## Troubleshooting
309
 
259
 
310
 #### Q: iOS - App crashes as soon as I request permission
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
 #### Q: iOS - App crashes when I change permission from settings
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".