Browse Source

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 years ago
parent
commit
f432ba6d7c
3 changed files with 9 additions and 4 deletions
  1. 3
    2
      ReactNativePermissions.js
  2. 4
    1
      permissions/RNPContacts.m
  3. 2
    1
      permissions/RNPPhoto.m

+ 3
- 2
ReactNativePermissions.js View File

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

+ 4
- 1
permissions/RNPContacts.m View File

59
 #else
59
 #else
60
     CFErrorRef error = nil;
60
     CFErrorRef error = nil;
61
     ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(nil, &error);
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
 #endif
66
 #endif
64
 }
67
 }
65
 
68
 

+ 2
- 1
permissions/RNPPhoto.m View File

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