瀏覽代碼

Merge branch 'master' of https://github.com/joshblour/react-native-permissions

* 'master' of https://github.com/joshblour/react-native-permissions:
  use indexOf for list
  change back the deployment target setting
  fix for iOS 8: includes is undefined
  fix iOS 8 compling errors

# Conflicts:
#	ReactNativePermissions.js
Yonah Forst 8 年之前
父節點
當前提交
f432ba6d7c
共有 3 個文件被更改,包括 9 次插入4 次删除
  1. 3
    2
      ReactNativePermissions.js
  2. 4
    1
      permissions/RNPContacts.m
  3. 2
    1
      permissions/RNPPhoto.m

+ 3
- 2
ReactNativePermissions.js 查看文件

@@ -56,8 +56,9 @@ class ReactNativePermissions {
56 56
 		return RNPTypes[Platform.OS];
57 57
 	}
58 58
 
59
+
59 60
 	getPermissionStatus(permission) {
60
-		if (this.getPermissionTypes().includes(permission)) {
61
+  	if (RNPTypes.indexOf(permission) >= 0) {
61 62
 			return RNPermissions.getPermissionStatus(permission)
62 63
 		} else {
63 64
 			return Promise.reject(`ReactNativePermissions: ${permission} is not a valid permission type on ${Platform.OS}`)
@@ -106,4 +107,4 @@ class ReactNativePermissions {
106 107
 	}
107 108
 }
108 109
 
109
-module.exports = new ReactNativePermissions()
110
+module.exports = new ReactNativePermissions()

+ 4
- 1
permissions/RNPContacts.m 查看文件

@@ -59,7 +59,10 @@
59 59
 #else
60 60
     CFErrorRef error = nil;
61 61
     ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(nil, &error);
62
-    ABAddressBookRequestAccessWithCompletion(addressBook, completionHandler);
62
+    ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
63
+        NSError *err = (__bridge NSError *)error;
64
+        handler(granted, err);
65
+    });
63 66
 #endif
64 67
 }
65 68
 

+ 2
- 1
permissions/RNPPhoto.m 查看文件

@@ -7,6 +7,7 @@
7 7
 //
8 8
 
9 9
 #import "RNPPhoto.h"
10
+#import <AddressBook/AddressBook.h>
10 11
 #import <AssetsLibrary/AssetsLibrary.h>
11 12
 
12 13
 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0
@@ -59,7 +60,7 @@
59 60
 #else
60 61
     ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
61 62
     [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
62
-        handler()
63
+        handler();
63 64
         *stop = YES;
64 65
     } failureBlock:^(NSError *error) {
65 66
         handler();