Skip to content

Commit c40e2ab

Browse files
author
matthieu.hocquart
committed
Use a object as second argument
1 parent 8607486 commit c40e2ab

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

index.android.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ReactNativePermissions {
6060
}
6161

6262

63-
request(permission, rationale) {
63+
request(permission, { rationale }) {
6464
const androidPermission = RNPTypes[permission]
6565
if (!androidPermission) return Promise.reject(`ReactNativePermissions: ${permission} is not a valid permission type on Android`);
6666

index.ios.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ class ReactNativePermissions {
4343
return RNPermissions.getPermissionStatus(permission, type);
4444
}
4545

46-
request(permission, type) {
46+
request(permission, options) {
47+
let type = null;
48+
if (typeof options === 'string' || options instanceof Array) {
49+
console.warn('[react-native-permissions] : You are using a deprecated version of request(). You should use an object as second parameter. Please check the documentation for more information : https://github.com/yonahforst/react-native-permissions');
50+
type = options;
51+
} else {
52+
type = options.type;
53+
}
54+
4755
if (!RNPTypes.includes(permission)) {
4856
return Promise.reject(`ReactNativePermissions: ${permission} is not a valid permission type on iOS`);
4957
}

0 commit comments

Comments
 (0)