Skip to content

Commit 0a6a273

Browse files
committed
Merge branch 'master' of github.com:react-native-community/react-native-permissions
2 parents 990641e + 8dad981 commit 0a6a273

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,28 @@ import {openSettings} from 'react-native-permissions';
554554
openSettings().catch(() => console.warn('cannot open settings'));
555555
```
556556

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+
557579
## Additional recipes
558580

559581
#### Check multiples permissions

0 commit comments

Comments
 (0)