Bladeren bron

Use a object as second argument

matthieu.hocquart 7 jaren geleden
bovenliggende
commit
c40e2ab6e3
2 gewijzigde bestanden met toevoegingen van 10 en 2 verwijderingen
  1. 1
    1
      index.android.js
  2. 9
    1
      index.ios.js

+ 1
- 1
index.android.js Bestand weergeven

@@ -60,7 +60,7 @@ class ReactNativePermissions {
60 60
 	}
61 61
 
62 62
 
63
-	request(permission, rationale) {
63
+	request(permission, { rationale }) {
64 64
 		const androidPermission = RNPTypes[permission]
65 65
   	if (!androidPermission) return Promise.reject(`ReactNativePermissions: ${permission} is not a valid permission type on Android`);
66 66
 

+ 9
- 1
index.ios.js Bestand weergeven

@@ -43,7 +43,15 @@ class ReactNativePermissions {
43 43
 		return RNPermissions.getPermissionStatus(permission, type);
44 44
 	}
45 45
 
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
+
47 55
 		if (!RNPTypes.includes(permission)) {
48 56
 			return Promise.reject(`ReactNativePermissions: ${permission} is not a valid permission type on iOS`);
49 57
 		}