Browse Source

Merge commit 'c40e2ab6e3'

# Conflicts:
#	index.android.js
#	index.ios.js
Kanta Asada 7 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 View File

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

+ 11
- 1
index.ios.js View File

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