Kanta Asada před 7 roky
rodič
revize
72f63b830a
2 změnil soubory, kde provedl 23 přidání a 21 odebrání
  1. 12
    12
      README.md
  2. 11
    9
      index.android.js

+ 12
- 12
README.md Zobrazit soubor

@@ -195,9 +195,11 @@ Permissions.request('location', { type: 'always' }).then(response => {
195 195
   this.setState({ locationPermission: response })
196 196
 })
197 197
 
198
-Permissions.request('notification', { type: ['alert', 'badge'] }).then(response => {
199
-  this.setState({ notificationPermission: response })
200
-})
198
+Permissions.request('notification', { type: ['alert', 'badge'] }).then(
199
+  response => {
200
+    this.setState({ notificationPermission: response })
201
+  },
202
+)
201 203
 ```
202 204
 
203 205
 * You cannot request microphone permissions on the simulator.
@@ -259,16 +261,14 @@ You can find more informations about this issue in #46.
259 261
 
260 262
 ```js
261 263
 // 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
-    },
264
+Permissions.request('camera', {
265
+  rationale: {
266
+    title: 'Cool Photo App Camera Permission',
267
+    message:
268
+      'Cool Photo App needs access to your camera ' +
269
+      'so you can take awesome pictures.',
270 270
   },
271
-).then(response => {
271
+}).then(response => {
272 272
   this.setState({ cameraPermission: response })
273 273
 })
274 274
 ```

+ 11
- 9
index.android.js Zobrazit soubor

@@ -61,7 +61,7 @@ class ReactNativePermissions {
61 61
     })
62 62
   }
63 63
 
64
-    request = (permission, { rationale }) => {
64
+  request = (permission, { rationale }) => {
65 65
     const androidPermission = permissionTypes[permission]
66 66
 
67 67
     if (!androidPermission) {
@@ -72,15 +72,17 @@ class ReactNativePermissions {
72 72
       )
73 73
     }
74 74
 
75
-    return PermissionsAndroid.request(androidPermission, rationale).then(result => {
76
-      // PermissionsAndroid.request() to native module resolves to boolean
77
-      // rather than string if running on OS version prior to Android M
78
-      if (typeof result === 'boolean') {
79
-        return result ? 'authorized' : 'denied'
80
-      }
75
+    return PermissionsAndroid.request(androidPermission, rationale).then(
76
+      result => {
77
+        // PermissionsAndroid.request() to native module resolves to boolean
78
+        // rather than string if running on OS version prior to Android M
79
+        if (typeof result === 'boolean') {
80
+          return result ? 'authorized' : 'denied'
81
+        }
81 82
 
82
-      return setDidAskOnce(permission).then(() => RESULTS[result])
83
-    })
83
+        return setDidAskOnce(permission).then(() => RESULTS[result])
84
+      },
85
+    )
84 86
   }
85 87
 
86 88
   checkMultiple = permissions =>