Bläddra i källkod

Merge commit 'c40e2ab6e3'

# Conflicts:
#	index.android.js
#	index.ios.js
Kanta Asada 7 år sedan
förälder
incheckning
9b28fd57c5
2 ändrade filer med 13 tillägg och 3 borttagningar
  1. 2
    2
      index.android.js
  2. 11
    1
      index.ios.js

+ 2
- 2
index.android.js Visa fil

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

+ 11
- 1
index.ios.js Visa fil

@@ -42,7 +42,15 @@ class ReactNativePermissions {
42 42
     )
43 43
   }
44 44
 
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
+
46 54
     if (!permissionTypes.includes(permission)) {
47 55
       return Promise.reject(
48 56
         `ReactNativePermissions: ${
@@ -57,6 +65,8 @@ class ReactNativePermissions {
57 65
       )
58 66
     }
59 67
 
68
+    
69
+
60 70
     return PermissionsIOS.requestPermission(
61 71
       permission,
62 72
       type || DEFAULTS[permission],