I am making macOS app with ExtensionKit.
When I call PHAssetCollection.requestAuthorization(for:handler:)
on my extension, it always gives .denied
without any prompts.
I've added com.apple.security.personal-information.photos-library
key into entitlements and NSPhotoLibraryUsageDescription
key into Info.plist but has no effects. Also Security Policy of my MacBook is Reduced Security and my host app gets .authorized
status but extension gives .denined
.
Does PhotoKit support ExtensionKit? Any ideas?
void (^requestAuthorization)(void (^completion)(NSError * _Nullable)) = ^(void (^completion)(NSError * _Nullable)) {
[PHPhotoLibrary requestAuthorizationForAccessLevel:PHAccessLevelReadWrite handler:^(PHAuthorizationStatus status) {
switch (status) {
case PHAuthorizationStatusNotDetermined:
requestAuthorization(completion);
break;
case PHAuthorizationStatusAuthorized:
completion(nil);
break;
default: {
NSLog(@"%lu", status); // gives 2, PHAuthorizationStatusDenied
NSError *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadNoPermissionError userInfo:nil];
completion(error);
break;
}
}
}];
};