Skip to content

Commit 9b28fd5

Browse files
author
Kanta Asada
committed
Merge commit 'c40e2ab6e35313729996732a8eb129974090f324'
# Conflicts: # index.android.js # index.ios.js
2 parents 4db9292 + c40e2ab commit 9b28fd5

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

index.android.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ReactNativePermissions {
6161
})
6262
}
6363

64-
request = permission => {
64+
request = (permission, { rationale }) => {
6565
const androidPermission = permissionTypes[permission]
6666

6767
if (!androidPermission) {
@@ -72,7 +72,7 @@ class ReactNativePermissions {
7272
)
7373
}
7474

75-
return PermissionsAndroid.request(androidPermission).then(result => {
75+
return PermissionsAndroid.request(androidPermission, rationale).then(result => {
7676
// PermissionsAndroid.request() to native module resolves to boolean
7777
// rather than string if running on OS version prior to Android M
7878
if (typeof result === 'boolean') {

index.ios.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@ class ReactNativePermissions {
4242
)
4343
}
4444

45-
request = (permission, type) => {
45+
request = (permission, options) => {
46+
let type = null;
47+
if (typeof options === 'string' || options instanceof Array) {
48+
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');
49+
type = options;
50+
} else if (options != null) {
51+
type = options.type;
52+
}
53+
4654
if (!permissionTypes.includes(permission)) {
4755
return Promise.reject(
4856
`ReactNativePermissions: ${
@@ -57,6 +65,8 @@ class ReactNativePermissions {
5765
)
5866
}
5967

68+
69+
6070
return PermissionsIOS.requestPermission(
6171
permission,
6272
type || DEFAULTS[permission],

0 commit comments

Comments
 (0)