Browse Source

Merge branch 'master' of github.com:react-native-community/react-native-permissions

Mathieu Acthernoene 5 years ago
parent
commit
0a6a273afe
1 changed files with 22 additions and 0 deletions
  1. 22
    0
      README.md

+ 22
- 0
README.md View File

554
 openSettings().catch(() => console.warn('cannot open settings'));
554
 openSettings().catch(() => console.warn('cannot open settings'));
555
 ```
555
 ```
556
 
556
 
557
+## Migrating from v1.x.x
558
+
559
+If you are currently using the version `1.x.x` and would like to switch to `v2.x.x`, the only thing you really need to know is that it's now required to select the wanted permission **per platform**.
560
+
561
+```js
562
+// v1.x.x
563
+import Permissions from 'react-native-permissions';
564
+
565
+Permissions.request('location', {type: 'whenInUse'});
566
+
567
+// v2.x.x
568
+import {Platform} from 'react-native';
569
+import {PERMISSIONS, request} from 'react-native-permissions';
570
+
571
+request(
572
+  Platform.select({
573
+    android: PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
574
+    ios: PERMISSIONS.IOS.LOCATION_WHEN_IN_USE,
575
+  }),
576
+);
577
+```
578
+
557
 ## Additional recipes
579
 ## Additional recipes
558
 
580
 
559
 #### Check multiples permissions
581
 #### Check multiples permissions