|
@@ -10,15 +10,12 @@
|
10
|
10
|
#import <AddressBook/AddressBook.h>
|
11
|
11
|
#import <AssetsLibrary/AssetsLibrary.h>
|
12
|
12
|
|
13
|
|
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0
|
14
|
13
|
@import Photos;
|
15
|
|
-#endif
|
16
|
14
|
|
17
|
15
|
@implementation RNPPhoto
|
18
|
16
|
|
19
|
17
|
+ (NSString *)getStatus
|
20
|
18
|
{
|
21
|
|
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0
|
22
|
19
|
int status = [PHPhotoLibrary authorizationStatus];
|
23
|
20
|
switch (status) {
|
24
|
21
|
case PHAuthorizationStatusAuthorized:
|
|
@@ -30,19 +27,6 @@
|
30
|
27
|
default:
|
31
|
28
|
return RNPStatusUndetermined;
|
32
|
29
|
}
|
33
|
|
-#else
|
34
|
|
- int status = ABAddressBookGetAuthorizationStatus();
|
35
|
|
- switch (status) {
|
36
|
|
- case kABAuthorizationStatusAuthorized:
|
37
|
|
- return RNPStatusAuthorized;
|
38
|
|
- case kABAuthorizationStatusDenied:
|
39
|
|
- return RNPStatusDenied;
|
40
|
|
- case kABAuthorizationStatusRestricted:
|
41
|
|
- return RNPStatusRestricted;
|
42
|
|
- default:
|
43
|
|
- return RNPStatusUndetermined;
|
44
|
|
- }
|
45
|
|
-#endif
|
46
|
30
|
}
|
47
|
31
|
|
48
|
32
|
+ (void)request:(void (^)(NSString *))completionHandler
|
|
@@ -52,19 +36,9 @@
|
52
|
36
|
completionHandler([self.class getStatus]);
|
53
|
37
|
});
|
54
|
38
|
};
|
55
|
|
-
|
56
|
|
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0
|
|
39
|
+
|
57
|
40
|
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
|
58
|
41
|
handler();
|
59
|
42
|
}];
|
60
|
|
-#else
|
61
|
|
- ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
|
62
|
|
- [library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
|
63
|
|
- handler();
|
64
|
|
- *stop = YES;
|
65
|
|
- } failureBlock:^(NSError *error) {
|
66
|
|
- handler();
|
67
|
|
- }];
|
68
|
|
-#endif
|
69
|
43
|
}
|
70
|
44
|
@end
|