Procházet zdrojové kódy

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

Mathieu Acthernoene před 5 roky
rodič
revize
0a6a273afe
1 změnil soubory, kde provedl 22 přidání a 0 odebrání
  1. 22
    0
      README.md

+ 22
- 0
README.md Zobrazit soubor

@@ -554,6 +554,28 @@ import {openSettings} from 'react-native-permissions';
554 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 579
 ## Additional recipes
558 580
 
559 581
 #### Check multiples permissions