Browse Source

Update dependencies + format

Mathieu Acthernoene 4 years ago
parent
commit
89881506a2
7 changed files with 989 additions and 412 deletions
  1. 91
    1
      .flowconfig
  2. 42
    43
      README.md
  3. 2
    2
      index.js
  4. 37
    41
      lib/permissions.android.js
  5. 36
    40
      lib/permissions.ios.js
  6. 21
    11
      package.json
  7. 760
    274
      yarn.lock

+ 91
- 1
.flowconfig View File

@@ -1,9 +1,99 @@
1 1
 [ignore]
2
+; We fork some components by platform
3
+.*/*[.]android.js
4
+
5
+; Ignore "BUCK" generated dirs
6
+<PROJECT_ROOT>/\.buckd/
7
+
8
+; Ignore unexpected extra "@providesModule"
9
+.*/node_modules/.*/node_modules/fbjs/.*
10
+
11
+; Ignore duplicate module providers
12
+; For RN Apps installed via npm, "Libraries" folder is inside
13
+; "node_modules/react-native" but in the source repo it is in the root
14
+example/node_modules/react-native/Libraries/react-native/React.js
15
+
16
+; Ignore polyfills
17
+example/node_modules/react-native/Libraries/polyfills/.*
18
+
19
+; These should not be required directly
20
+; require from fbjs/lib instead: require('fbjs/lib/warning')
21
+example/node_modules/warning/.*
22
+
23
+; Flow doesn't support platforms
24
+.*/Libraries/Utilities/HMRLoadingView.js
25
+
26
+[untyped]
27
+.*/node_modules/@react-native-community/cli/.*/.*
2 28
 
3 29
 [include]
4 30
 
5 31
 [libs]
32
+example/node_modules/react-native/Libraries/react-native/react-native-interface.js
33
+example/node_modules/react-native/flow/
34
+
35
+[options]
36
+emoji=true
37
+
38
+esproposal.optional_chaining=enable
39
+esproposal.nullish_coalescing=enable
40
+
41
+module.file_ext=.js
42
+module.file_ext=.json
43
+module.file_ext=.ios.js
44
+
45
+module.system=haste
46
+module.system.haste.use_name_reducers=true
47
+# get basename
48
+module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
49
+# strip .js or .js.flow suffix
50
+module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
51
+# strip .ios suffix
52
+module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
53
+module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
54
+module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
55
+module.system.haste.paths.blacklist=.*/__tests__/.*
56
+module.system.haste.paths.blacklist=.*/__mocks__/.*
57
+module.system.haste.paths.whitelist=<PROJECT_ROOT>/example/node_modules/react-native/Libraries/.*
58
+module.system.haste.paths.whitelist=<PROJECT_ROOT>/example/node_modules/react-native/RNTester/.*
59
+module.system.haste.paths.whitelist=<PROJECT_ROOT>/example/node_modules/react-native/IntegrationTests/.*
60
+module.system.haste.paths.blacklist=<PROJECT_ROOT>/example/node_modules/react-native/Libraries/react-native/react-native-implementation.js
61
+module.system.haste.paths.blacklist=<PROJECT_ROOT>/example/node_modules/react-native/Libraries/Animated/src/polyfills/.*
62
+
63
+munge_underscores=true
64
+
65
+module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
66
+
67
+suppress_type=$FlowIssue
68
+suppress_type=$FlowFixMe
69
+suppress_type=$FlowFixMeProps
70
+suppress_type=$FlowFixMeState
71
+
72
+suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
73
+suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
74
+suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
6 75
 
7 76
 [lints]
77
+sketchy-null-number=warn
78
+sketchy-null-mixed=warn
79
+sketchy-number=warn
80
+untyped-type-import=warn
81
+nonstrict-import=warn
82
+deprecated-type=warn
83
+unsafe-getters-setters=warn
84
+inexact-spread=warn
85
+unnecessary-invariant=warn
86
+signature-verification-failure=warn
87
+deprecated-utility=error
8 88
 
9
-[options]
89
+[strict]
90
+deprecated-type
91
+nonstrict-import
92
+sketchy-null
93
+unclear-type
94
+unsafe-getters-setters
95
+untyped-import
96
+untyped-type-import
97
+
98
+[version]
99
+^0.98.0

+ 42
- 43
README.md View File

@@ -20,12 +20,12 @@ _Complies with
20 20
 
21 21
 ## ⚠️ Breaking changes in version 1.0.0
22 22
 
23
-* Now using React Native's own JS `PermissionsAndroid` module on Android, which
23
+- Now using React Native's own JS `PermissionsAndroid` module on Android, which
24 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
25
+- Updated API to be closer to React Native's `PermissionsAndroid`
26
+- Removed `openSettings()` support on Android (to stay linking-free). There are
27 27
   several NPM modules available for this
28
-* `restricted` status now supported on Android, although it means something
28
+- `restricted` status now supported on Android, although it means something
29 29
   different than iOS
30 30
 
31 31
 ## Setup
@@ -62,13 +62,12 @@ react-native link react-native-permissions
62 62
    folder ➜ `Add Files to <...>`
63 63
 2. Go to `node_modules` ➜ `react-native-permissions` ➜ select
64 64
    `ReactNativePermissions.xcodeproj`
65
-3. Add `libReactNativePermissions.a` to `Build Phases` -> `Link Binary With
66
-   Libraries`
65
+3. Add `libReactNativePermissions.a` to `Build Phases` -> `Link Binary With Libraries`
67 66
 
68 67
 ## Using
69 68
 
70 69
 ```js
71
-import Permissions from 'react-native-permissions'
70
+import Permissions from 'react-native-permissions';
72 71
 // OR const Permissions = require('react-native-permissions').default
73 72
 // if you use CommonJS module system
74 73
 
@@ -81,8 +80,8 @@ export default class extends React.Component {
81 80
   componentDidMount() {
82 81
     Permissions.check('photo').then(response => {
83 82
       // Response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
84
-      this.setState({ photoPermission: response })
85
-    })
83
+      this.setState({photoPermission: response});
84
+    });
86 85
   }
87 86
 
88 87
   // Request permission to access photos
@@ -90,9 +89,9 @@ export default class extends React.Component {
90 89
     Permissions.request('photo').then(response => {
91 90
       // Returns once the user has chosen to 'allow' or to 'not allow' access
92 91
       // Response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
93
-      this.setState({ photoPermission: response })
94
-    })
95
-  }
92
+      this.setState({photoPermission: response});
93
+    });
94
+  };
96 95
 
97 96
   // Check the status of multiple permissions
98 97
   _checkCameraAndPhotos = () => {
@@ -101,9 +100,9 @@ export default class extends React.Component {
101 100
       this.setState({
102 101
         cameraPermission: response.camera,
103 102
         photoPermission: response.photo,
104
-      })
105
-    })
106
-  }
103
+      });
104
+    });
105
+  };
107 106
 
108 107
   // This is a common pattern when asking for permissions.
109 108
   // iOS only gives you once chance to show the permission dialog,
@@ -122,10 +121,10 @@ export default class extends React.Component {
122 121
           style: 'cancel',
123 122
         },
124 123
         this.state.photoPermission == 'undetermined'
125
-          ? { text: 'OK', onPress: this._requestPermission }
126
-          : { text: 'Open Settings', onPress: Permissions.openSettings },
124
+          ? {text: 'OK', onPress: this._requestPermission}
125
+          : {text: 'Open Settings', onPress: Permissions.openSettings},
127 126
       ],
128
-    )
127
+    );
129 128
   }
130 129
 
131 130
   //...
@@ -141,7 +140,7 @@ Promises resolve into one of these statuses:
141 140
 | Return value   | Notes                                                                                                                                                                                                                                                                  |
142 141
 | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
143 142
 | `authorized`   | User has authorized this permission                                                                                                                                                                                                                                    |
144
-| `denied`       | User has denied this permission at least once. On iOS this means that the user will not be prompted again. Android users can be prompted multiple times until they select 'Never ask me again'                                                                          |
143
+| `denied`       | User has denied this permission at least once. On iOS this means that the user will not be prompted again. Android users can be prompted multiple times until they select 'Never ask me again'                                                                         |
145 144
 | `restricted`   | **iOS** - this means 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. **Android** - this means that the user has selected 'Never ask me again' while denying permission |
146 145
 | `undetermined` | User has not yet been prompted with a permission dialog                                                                                                                                                                                                                |
147 146
 
@@ -182,40 +181,39 @@ The current supported permissions are:
182 181
 
183 182
 ### iOS Notes
184 183
 
185
-* Permission type `bluetooth` represents the status of the
184
+- Permission type `bluetooth` represents the status of the
186 185
   `CBPeripheralManager`. Don't use this if you only need `CBCentralManager`.
187
-* Permission type `location` accepts a second parameter for `request()` and
186
+- Permission type `location` accepts a second parameter for `request()` and
188 187
   `check()`; the second parameter is a string, either `always` or `whenInUse`
189 188
   (default).
190
-* Permission type `notification` accepts a second parameter for `request()`. The
189
+- Permission type `notification` accepts a second parameter for `request()`. The
191 190
   second parameter is an array with the desired alert types. Any combination of
192 191
   `alert`, `badge` and `sound` (default requests all three).
193
-* If you are not requesting mediaLibrary then you can remove MediaPlayer.framework from the xcode project.
192
+- If you are not requesting mediaLibrary then you can remove MediaPlayer.framework from the xcode project.
194 193
 
195 194
 ```js
196 195
 // example
197
-Permissions.check('location', { type: 'always' }).then(response => {
198
-  this.setState({ locationPermission: response })
199
-})
196
+Permissions.check('location', {type: 'always'}).then(response => {
197
+  this.setState({locationPermission: response});
198
+});
200 199
 
201
-Permissions.request('location', { type: 'always' }).then(response => {
202
-  this.setState({ locationPermission: response })
203
-})
200
+Permissions.request('location', {type: 'always'}).then(response => {
201
+  this.setState({locationPermission: response});
202
+});
204 203
 
205
-Permissions.request('notification', { type: ['alert', 'badge'] }).then(
204
+Permissions.request('notification', {type: ['alert', 'badge']}).then(
206 205
   response => {
207
-    this.setState({ notificationPermission: response })
206
+    this.setState({notificationPermission: response});
208 207
   },
209
-)
208
+);
210 209
 ```
211 210
 
212
-* You cannot request microphone permissions on the simulator.
213
-* With Xcode 8, you now need to add usage descriptions for each permission you
211
+- You cannot request microphone permissions on the simulator.
212
+- With Xcode 8, you now need to add usage descriptions for each permission you
214 213
   will request. Open Xcode ➜ `Info.plist` ➜ Add a key (starting with "Privacy -
215 214
   ...") with your kit specific permission.
216 215
 
217
-Example: If you need Contacts permission you have to add the key `Privacy -
218
-Contacts Usage Description`.
216
+Example: If you need Contacts permission you have to add the key `Privacy - Contacts Usage Description`.
219 217
 
220 218
 <img width="338" alt="3cde3b44-7ffd-11e6-918b-63888e33f983" src="https://cloud.githubusercontent.com/assets/1440796/18713019/271be540-8011-11e6-87fb-c3828c172dfc.png">
221 219
 
@@ -248,6 +246,7 @@ So before submitting your app to the App Store, make sure that in your
248 246
 <key>NSMotionUsageDescription</key>
249 247
 <string>Some description</string>
250 248
 ```
249
+
251 250
 This is required because during the phase of processing in the App Store
252 251
 submission, the system detects that you app contains code to request the
253 252
 permission `X` but don't have the `UsageDescription` key and then it rejects the
@@ -260,16 +259,16 @@ You can find more information about this issue in #46.
260 259
 
261 260
 ### Android Notes
262 261
 
263
-* Uses React Native's own
262
+- Uses React Native's own
264 263
   [`PermissionsAndroid` JS API](http://facebook.github.io/react-native/docs/permissionsandroid.html).
265
-* All required permissions also need to be included in the `AndroidManifest.xml`
264
+- All required permissions also need to be included in the `AndroidManifest.xml`
266 265
   file before they can be requested. Otherwise `request()` will immediately
267 266
   return `denied`.
268
-* You can request write access to any of these types by also including the
267
+- You can request write access to any of these types by also including the
269 268
   appropriate write permission in the `AndroidManifest.xml` file. Read more
270 269
   [here](https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous).
271 270
 
272
-* The optional rationale argument will show a dialog prompt.
271
+- The optional rationale argument will show a dialog prompt.
273 272
 
274 273
 ```js
275 274
 // example
@@ -281,11 +280,11 @@ Permissions.request('camera', {
281 280
       'so you can take awesome pictures.',
282 281
   },
283 282
 }).then(response => {
284
-  this.setState({ cameraPermission: response })
285
-})
283
+  this.setState({cameraPermission: response});
284
+});
286 285
 ```
287 286
 
288
-* Permissions are automatically accepted for **targetSdkVersion < 23** but you
287
+- Permissions are automatically accepted for **targetSdkVersion < 23** but you
289 288
   can still use `check()` to check if the user has disabled them from Settings.
290 289
 
291 290
 You might need to elevate the **targetSdkVersion** version in your

+ 2
- 2
index.js View File

@@ -1,4 +1,4 @@
1 1
 // @flow
2 2
 
3
-import Permissions from './lib/permissions'
4
-export default Permissions
3
+import Permissions from './lib/permissions';
4
+export default Permissions;

+ 37
- 41
lib/permissions.android.js View File

@@ -1,11 +1,11 @@
1 1
 // @flow
2 2
 
3
-import { AsyncStorage, NativeModules, PermissionsAndroid } from 'react-native'
3
+import {AsyncStorage, NativeModules, PermissionsAndroid} from 'react-native';
4 4
 
5
-type Status = 'authorized' | 'denied' | 'restricted' | 'undetermined'
6
-type Rationale = { title: string, message: string }
7
-type CheckOptions = string | { type: string }
8
-type RequestOptions = string | { type: string, rationale?: Rationale }
5
+type Status = 'authorized' | 'denied' | 'restricted' | 'undetermined';
6
+type Rationale = {title: string, message: string};
7
+type CheckOptions = string | {type: string};
8
+type RequestOptions = string | {type: string, rationale?: Rationale};
9 9
 
10 10
 const permissionTypes = {
11 11
   location: PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
@@ -18,75 +18,71 @@ const permissionTypes = {
18 18
   callPhone: PermissionsAndroid.PERMISSIONS.CALL_PHONE,
19 19
   readSms: PermissionsAndroid.PERMISSIONS.READ_SMS,
20 20
   receiveSms: PermissionsAndroid.PERMISSIONS.RECEIVE_SMS,
21
-}
21
+};
22 22
 
23 23
 const RESULTS = {
24 24
   [PermissionsAndroid.RESULTS.GRANTED]: 'authorized',
25 25
   [PermissionsAndroid.RESULTS.DENIED]: 'denied',
26 26
   [PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN]: 'restricted',
27
-}
27
+};
28 28
 
29
-const STORAGE_KEY = '@RNPermissions:didAskPermission:'
29
+const STORAGE_KEY = '@RNPermissions:didAskPermission:';
30 30
 
31 31
 const setDidAskOnce = (permission: string) =>
32
-  AsyncStorage.setItem(STORAGE_KEY + permission, 'true')
32
+  AsyncStorage.setItem(STORAGE_KEY + permission, 'true');
33 33
 
34 34
 const getDidAskOnce = (permission: string) =>
35
-  AsyncStorage.getItem(STORAGE_KEY + permission).then(item => !!item)
35
+  AsyncStorage.getItem(STORAGE_KEY + permission).then(item => !!item);
36 36
 
37 37
 class ReactNativePermissions {
38
-  canOpenSettings: () => Promise<boolean> = () => Promise.resolve(false)
38
+  canOpenSettings: () => Promise<boolean> = () => Promise.resolve(false);
39 39
 
40 40
   openSettings: () => Promise<*> = () =>
41
-    Promise.reject(new Error("'openSettings' is deprecated on android"))
41
+    Promise.reject(new Error("'openSettings' is deprecated on android"));
42 42
 
43
-  getTypes: () => Array<string> = () => Object.keys(permissionTypes)
43
+  getTypes: () => Array<string> = () => Object.keys(permissionTypes);
44 44
 
45 45
   check = (permission: string, options?: CheckOptions): Promise<Status> => {
46 46
     if (!permissionTypes[permission]) {
47 47
       const error = new Error(
48
-        `ReactNativePermissions: ${
49
-          permission
50
-        } is not a valid permission type on Android`,
51
-      )
48
+        `ReactNativePermissions: ${permission} is not a valid permission type on Android`,
49
+      );
52 50
 
53
-      return Promise.reject(error)
51
+      return Promise.reject(error);
54 52
     }
55 53
 
56 54
     return PermissionsAndroid.check(permissionTypes[permission]).then(
57 55
       isAuthorized => {
58 56
         if (isAuthorized) {
59
-          return 'authorized'
57
+          return 'authorized';
60 58
         }
61 59
 
62 60
         return getDidAskOnce(permission).then(didAsk => {
63 61
           if (didAsk) {
64 62
             return NativeModules.PermissionsAndroid.shouldShowRequestPermissionRationale(
65 63
               permissionTypes[permission],
66
-            ).then(shouldShow => (shouldShow ? 'denied' : 'restricted'))
64
+            ).then(shouldShow => (shouldShow ? 'denied' : 'restricted'));
67 65
           }
68 66
 
69
-          return 'undetermined'
70
-        })
67
+          return 'undetermined';
68
+        });
71 69
       },
72
-    )
73
-  }
70
+    );
71
+  };
74 72
 
75 73
   request = (permission: string, options?: RequestOptions): Promise<Status> => {
76 74
     if (!permissionTypes[permission]) {
77 75
       const error = new Error(
78
-        `ReactNativePermissions: ${
79
-          permission
80
-        } is not a valid permission type on Android`,
81
-      )
76
+        `ReactNativePermissions: ${permission} is not a valid permission type on Android`,
77
+      );
82 78
 
83
-      return Promise.reject(error)
79
+      return Promise.reject(error);
84 80
     }
85 81
 
86
-    let rationale
82
+    let rationale;
87 83
 
88 84
     if (options && options.rationale) {
89
-      rationale = options.rationale
85
+      rationale = options.rationale;
90 86
     }
91 87
 
92 88
     return PermissionsAndroid.request(
@@ -96,22 +92,22 @@ class ReactNativePermissions {
96 92
       // PermissionsAndroid.request() to native module resolves to boolean
97 93
       // rather than string if running on OS version prior to Android M
98 94
       if (typeof result === 'boolean') {
99
-        return result ? 'authorized' : 'denied'
95
+        return result ? 'authorized' : 'denied';
100 96
       }
101 97
 
102
-      return setDidAskOnce(permission).then(() => RESULTS[result])
103
-    })
104
-  }
98
+      return setDidAskOnce(permission).then(() => RESULTS[result]);
99
+    });
100
+  };
105 101
 
106
-  checkMultiple = (permissions: Array<string>): Promise<{ [string]: string }> =>
102
+  checkMultiple = (permissions: Array<string>): Promise<{[string]: string}> =>
107 103
     Promise.all(permissions.map(permission => this.check(permission))).then(
108 104
       result =>
109 105
         result.reduce((acc, value, index) => {
110
-          const name = permissions[index]
111
-          acc[name] = value
112
-          return acc
106
+          const name = permissions[index];
107
+          acc[name] = value;
108
+          return acc;
113 109
         }, {}),
114
-    )
110
+    );
115 111
 }
116 112
 
117
-export default new ReactNativePermissions()
113
+export default new ReactNativePermissions();

+ 36
- 40
lib/permissions.ios.js View File

@@ -1,12 +1,12 @@
1 1
 // @flow
2 2
 
3
-import { NativeModules } from 'react-native'
4
-const PermissionsIOS = NativeModules.ReactNativePermissions
3
+import {NativeModules} from 'react-native';
4
+const PermissionsIOS = NativeModules.ReactNativePermissions;
5 5
 
6
-type Status = 'authorized' | 'denied' | 'restricted' | 'undetermined'
7
-type Rationale = { title: string, message: string }
8
-type CheckOptions = string | { type: string }
9
-type RequestOptions = string | { type: string, rationale?: Rationale }
6
+type Status = 'authorized' | 'denied' | 'restricted' | 'undetermined';
7
+type Rationale = {title: string, message: string};
8
+type CheckOptions = string | {type: string};
9
+type RequestOptions = string | {type: string, rationale?: Rationale};
10 10
 
11 11
 const permissionTypes = [
12 12
   'location',
@@ -21,89 +21,85 @@ const permissionTypes = [
21 21
   'backgroundRefresh',
22 22
   'speechRecognition',
23 23
   'mediaLibrary',
24
-  'motion'
25
-]
24
+  'motion',
25
+];
26 26
 
27 27
 const DEFAULTS = {
28 28
   location: 'whenInUse',
29 29
   notification: ['alert', 'badge', 'sound'],
30
-}
30
+};
31 31
 
32 32
 class ReactNativePermissions {
33 33
   canOpenSettings: () => Promise<boolean> = () =>
34
-    PermissionsIOS.canOpenSettings()
34
+    PermissionsIOS.canOpenSettings();
35 35
 
36
-  openSettings: () => Promise<*> = () => PermissionsIOS.openSettings()
36
+  openSettings: () => Promise<*> = () => PermissionsIOS.openSettings();
37 37
 
38
-  getTypes: () => Array<string> = () => permissionTypes
38
+  getTypes: () => Array<string> = () => permissionTypes;
39 39
 
40 40
   check = (permission: string, options?: CheckOptions): Promise<Status> => {
41 41
     if (!permissionTypes.includes(permission)) {
42 42
       const error = new Error(
43
-        `ReactNativePermissions: ${
44
-          permission
45
-        } is not a valid permission type on iOS`,
46
-      )
43
+        `ReactNativePermissions: ${permission} is not a valid permission type on iOS`,
44
+      );
47 45
 
48
-      return Promise.reject(error)
46
+      return Promise.reject(error);
49 47
     }
50 48
 
51
-    let type
49
+    let type;
52 50
 
53 51
     if (typeof options === 'string') {
54
-      type = options
52
+      type = options;
55 53
     } else if (options && options.type) {
56
-      type = options.type
54
+      type = options.type;
57 55
     }
58 56
 
59 57
     return PermissionsIOS.getPermissionStatus(
60 58
       permission,
61 59
       type || DEFAULTS[permission],
62
-    )
63
-  }
60
+    );
61
+  };
64 62
 
65 63
   request = (permission: string, options?: RequestOptions): Promise<Status> => {
66 64
     if (!permissionTypes.includes(permission)) {
67 65
       const error = new Error(
68
-        `ReactNativePermissions: ${
69
-          permission
70
-        } is not a valid permission type on iOS`,
71
-      )
66
+        `ReactNativePermissions: ${permission} is not a valid permission type on iOS`,
67
+      );
72 68
 
73
-      return Promise.reject(error)
69
+      return Promise.reject(error);
74 70
     }
75 71
 
76 72
     if (permission == 'backgroundRefresh') {
77 73
       const error = new Error(
78 74
         'ReactNativePermissions: You cannot request backgroundRefresh',
79
-      )
75
+      );
80 76
 
81
-      return Promise.reject(error)
77
+      return Promise.reject(error);
82 78
     }
83 79
 
84
-    let type
80
+    let type;
85 81
 
86 82
     if (typeof options === 'string') {
87
-      type = options
83
+      type = options;
88 84
     } else if (options && options.type) {
89
-      type = options.type
85
+      type = options.type;
90 86
     }
91 87
 
92 88
     return PermissionsIOS.requestPermission(
93 89
       permission,
94 90
       type || DEFAULTS[permission],
95
-    )
96
-  }
91
+    );
92
+  };
97 93
 
98
-  checkMultiple = (permissions: Array<string>): Promise<{ [string]: string }> =>
94
+  checkMultiple = (permissions: Array<string>): Promise<{[string]: string}> =>
99 95
     Promise.all(permissions.map(permission => this.check(permission))).then(
100 96
       result =>
101 97
         result.reduce((acc, value, index) => {
102
-          const name = permissions[index]
103
-          acc[name] = value
104
-          return acc
98
+          const name = permissions[index];
99
+          acc[name] = value;
100
+          return acc;
105 101
         }, {}),
106
-    )
102
+    );
107 103
 }
108 104
 
109
-export default new ReactNativePermissions()
105
+export default new ReactNativePermissions();

+ 21
- 11
package.json View File

@@ -1,27 +1,37 @@
1 1
 {
2 2
   "name": "react-native-permissions",
3
-  "version": "1.1.1",
3
+  "version": "1.2.0",
4 4
   "description": "Check user permissions in React Native",
5 5
   "author": "Yonah Forst <yonaforst@hotmail.com>",
6
-  "homepage": "https://github.com/yonahforst/react-native-permissions",
7
-  "keywords": ["react-native", "react-permissions", "permissions"],
8
-  "main": "index.js",
9 6
   "license": "MIT",
7
+  "main": "index.js",
8
+  "homepage": "https://github.com/react-native-community/react-native-permissions#readme",
10 9
   "repository": {
11 10
     "type": "git",
12
-    "url": "https://github.com/yonahforst/react-native-permissions.git"
11
+    "url": "https://github.com/react-native-community/react-native-permissions.git"
13 12
   },
13
+  "keywords": [
14
+    "react-native",
15
+    "react native",
16
+    "react-permissions",
17
+    "permissions",
18
+    "authorization"
19
+  ],
14 20
   "scripts": {
15 21
     "precommit": "lint-staged",
16
-    "prettier": "prettier --write '**/*.{js,json,md}'"
22
+    "typecheck": "flow .",
23
+    "format": "prettier --write '**/*.{js,json,md,ts,tsx}'"
17 24
   },
18 25
   "lint-staged": {
19
-    "**/*.{js,json,md}": ["prettier --write", "git add"]
26
+    "**/*.{js,json,md,ts,tsx}": [
27
+      "prettier --write",
28
+      "git add"
29
+    ]
20 30
   },
21 31
   "devDependencies": {
22
-    "flow-bin": "^0.57.3",
23
-    "husky": "^0.14.3",
24
-    "lint-staged": "^6.0.0",
25
-    "prettier": "^1.9.2"
32
+    "flow-bin": "0.98.0",
33
+    "husky": "3.0.0",
34
+    "lint-staged": "9.2.0",
35
+    "prettier": "1.18.2"
26 36
   }
27 37
 }

+ 760
- 274
yarn.lock
File diff suppressed because it is too large
View File