Browse Source

Merge commit 'c40e2ab6e35313729996732a8eb129974090f324'

# Conflicts:
#	index.android.js
#	index.ios.js
Kanta Asada 8 years ago
parent
commit
9b28fd57c5
2 changed files with 13 additions and 3 deletions
  1. 2 2
      index.android.js
  2. 11 1
      index.ios.js

+ 2 - 2
index.android.js

@@ -61,7 +61,7 @@ class ReactNativePermissions {
     })
   }
 
-  request = permission => {
+    request = (permission, { rationale }) => {
     const androidPermission = permissionTypes[permission]
 
     if (!androidPermission) {
@@ -72,7 +72,7 @@ class ReactNativePermissions {
       )
     }
 
-    return PermissionsAndroid.request(androidPermission).then(result => {
+    return PermissionsAndroid.request(androidPermission, rationale).then(result => {
       // PermissionsAndroid.request() to native module resolves to boolean
       // rather than string if running on OS version prior to Android M
       if (typeof result === 'boolean') {

+ 11 - 1
index.ios.js

@@ -42,7 +42,15 @@ class ReactNativePermissions {
     )
   }
 
-  request = (permission, type) => {
+  request = (permission, options) => {
+    let type = null;
+    if (typeof options === 'string' || options instanceof Array) {
+      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');
+      type = options;
+    } else if (options != null) {
+      type = options.type;
+    }
+
     if (!permissionTypes.includes(permission)) {
       return Promise.reject(
         `ReactNativePermissions: ${
@@ -57,6 +65,8 @@ class ReactNativePermissions {
       )
     }
 
+    
+
     return PermissionsIOS.requestPermission(
       permission,
       type || DEFAULTS[permission],