Mathieu Acthernoene 5 年前
父节点
当前提交
8dad981b27
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22
    0
      README.md

+ 22
- 0
README.md 查看文件

@@ -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