Browse Source

Update README.md.

Kanta Asada 7 years ago
parent
commit
cac15f6057
1 changed files with 22 additions and 3 deletions
  1. 22
    3
      README.md

+ 22
- 3
README.md View File

187
 
187
 
188
 ```js
188
 ```js
189
 // example
189
 // example
190
-Permissions.check('location', 'always').then(response => {
190
+Permissions.check('location', { type: 'always' }).then(response => {
191
   this.setState({ locationPermission: response })
191
   this.setState({ locationPermission: response })
192
 })
192
 })
193
 
193
 
194
-Permissions.request('location', 'always').then(response => {
194
+Permissions.request('location', { type: 'always' }).then(response => {
195
   this.setState({ locationPermission: response })
195
   this.setState({ locationPermission: response })
196
 })
196
 })
197
 
197
 
198
-Permissions.request('notification', ['alert', 'badge']).then(response => {
198
+Permissions.request('notification', { type: ['alert', 'badge'] }).then(response => {
199
   this.setState({ notificationPermission: response })
199
   this.setState({ notificationPermission: response })
200
 })
200
 })
201
 ```
201
 ```
254
 * You can request write access to any of these types by also including the
254
 * You can request write access to any of these types by also including the
255
   appropriate write permission in the `AndroidManifest.xml` file. Read more
255
   appropriate write permission in the `AndroidManifest.xml` file. Read more
256
   [here](https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous).
256
   [here](https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous).
257
+
258
+* The optional rationale argument will show a dialog prompt.
259
+
260
+```js
261
+// example
262
+Permissions.request(
263
+  'camera',
264
+  {
265
+    rationale: {
266
+      'title': 'Cool Photo App Camera Permission',
267
+      'message': 'Cool Photo App needs access to your camera ' +
268
+                 'so you can take awesome pictures.'
269
+    },
270
+  },
271
+).then(response => {
272
+  this.setState({ cameraPermission: response })
273
+})
274
+```
275
+
257
 * Permissions are automatically accepted for **targetSdkVersion < 23** but you
276
 * Permissions are automatically accepted for **targetSdkVersion < 23** but you
258
   can still use `check()` to check if the user has disabled them from Settings.
277
   can still use `check()` to check if the user has disabled them from Settings.
259
 
278