Browse Source

Use a object as second argument

matthieu.hocquart 8 years ago
parent
commit
c40e2ab6e3
2 changed files with 10 additions and 2 deletions
  1. 1 1
      index.android.js
  2. 9 1
      index.ios.js

+ 1 - 1
index.android.js

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

+ 9 - 1
index.ios.js

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