@@ -20,12 +20,12 @@ _Complies with
2020
2121## ⚠️ Breaking changes in version 1.0.0
2222
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
2424 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
2727 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
2929 different than iOS
3030
3131## Setup
@@ -62,13 +62,12 @@ react-native link react-native-permissions
6262 folder ➜ ` Add Files to <...> `
63632 . Go to ` node_modules ` ➜ ` react-native-permissions ` ➜ select
6464 ` 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 `
6766
6867## Using
6968
7069``` js
71- import Permissions from ' react-native-permissions'
70+ import Permissions from ' react-native-permissions' ;
7271// OR const Permissions = require('react-native-permissions').default
7372// if you use CommonJS module system
7473
@@ -81,18 +80,18 @@ export default class extends React.Component {
8180 componentDidMount () {
8281 Permissions .check (' photo' ).then (response => {
8382 // Response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
84- this .setState ({ photoPermission: response })
85- })
83+ this .setState ({photoPermission: response});
84+ });
8685 }
8786
8887 // Request permission to access photos
8988 _requestPermission = () => {
9089 Permissions .request (' photo' ).then (response => {
9190 // Returns once the user has chosen to 'allow' or to 'not allow' access
9291 // Response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
93- this .setState ({ photoPermission: response })
94- })
95- }
92+ this .setState ({photoPermission: response});
93+ });
94+ };
9695
9796 // Check the status of multiple permissions
9897 _checkCameraAndPhotos = () => {
@@ -101,9 +100,9 @@ export default class extends React.Component {
101100 this .setState ({
102101 cameraPermission: response .camera ,
103102 photoPermission: response .photo ,
104- })
105- })
106- }
103+ });
104+ });
105+ };
107106
108107 // This is a common pattern when asking for permissions.
109108 // iOS only gives you once chance to show the permission dialog,
@@ -122,10 +121,10 @@ export default class extends React.Component {
122121 style: ' cancel' ,
123122 },
124123 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 },
127126 ],
128- )
127+ );
129128 }
130129
131130 // ...
@@ -141,7 +140,7 @@ Promises resolve into one of these statuses:
141140| Return value | Notes |
142141| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
143142| ` 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' |
145144| ` 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 |
146145| ` undetermined ` | User has not yet been prompted with a permission dialog |
147146
@@ -182,40 +181,39 @@ The current supported permissions are:
182181
183182### iOS Notes
184183
185- * Permission type ` bluetooth ` represents the status of the
184+ - Permission type ` bluetooth ` represents the status of the
186185 ` 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
188187 ` check() ` ; the second parameter is a string, either ` always ` or ` whenInUse `
189188 (default).
190- * Permission type ` notification ` accepts a second parameter for ` request() ` . The
189+ - Permission type ` notification ` accepts a second parameter for ` request() ` . The
191190 second parameter is an array with the desired alert types. Any combination of
192191 ` 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.
194193
195194``` js
196195// 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+ });
200199
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+ });
204203
205- Permissions .request (' notification' , { type: [' alert' , ' badge' ] }).then (
204+ Permissions .request (' notification' , {type: [' alert' , ' badge' ]}).then (
206205 response => {
207- this .setState ({ notificationPermission: response })
206+ this .setState ({notificationPermission: response});
208207 },
209- )
208+ );
210209```
211210
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
214213 will request. Open Xcode ➜ ` Info.plist ` ➜ Add a key (starting with "Privacy -
215214 ...") with your kit specific permission.
216215
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 ` .
219217
220218<img width =" 338 " alt =" 3cde3b44-7ffd-11e6-918b-63888e33f983 " src =" https://cloud.githubusercontent.com/assets/1440796/18713019/271be540-8011-11e6-87fb-c3828c172dfc.png " >
221219
@@ -248,6 +246,7 @@ So before submitting your app to the App Store, make sure that in your
248246<key >NSMotionUsageDescription</key >
249247<string >Some description</string >
250248```
249+
251250This is required because during the phase of processing in the App Store
252251submission, the system detects that you app contains code to request the
253252permission ` 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.
260259
261260### Android Notes
262261
263- * Uses React Native's own
262+ - Uses React Native's own
264263 [ ` 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 `
266265 file before they can be requested. Otherwise ` request() ` will immediately
267266 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
269268 appropriate write permission in the ` AndroidManifest.xml ` file. Read more
270269 [ here] ( https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous ) .
271270
272- * The optional rationale argument will show a dialog prompt.
271+ - The optional rationale argument will show a dialog prompt.
273272
274273``` js
275274// example
@@ -281,11 +280,11 @@ Permissions.request('camera', {
281280 ' so you can take awesome pictures.' ,
282281 },
283282}).then (response => {
284- this .setState ({ cameraPermission: response })
285- })
283+ this .setState ({cameraPermission: response});
284+ });
286285```
287286
288- * Permissions are automatically accepted for ** targetSdkVersion < 23** but you
287+ - Permissions are automatically accepted for ** targetSdkVersion < 23** but you
289288 can still use ` check() ` to check if the user has disabled them from Settings.
290289
291290You might need to elevate the ** targetSdkVersion** version in your
0 commit comments