diff --git a/src/ios/SOSPicker.m b/src/ios/SOSPicker.m index 0e2e00e7..6d81ffd4 100644 --- a/src/ios/SOSPicker.m +++ b/src/ios/SOSPicker.m @@ -40,7 +40,7 @@ - (void) requestReadPermission:(CDVInvokedUrlCommand *)command { if (status == PHAuthorizationStatusAuthorized) { NSLog(@"Access has been granted."); - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:true]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } else if (status == PHAuthorizationStatusDenied) { NSString* message = @"Access has been denied. Change your setting > this app > Photo enable"; @@ -49,11 +49,27 @@ - (void) requestReadPermission:(CDVInvokedUrlCommand *)command { CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } else if (status == PHAuthorizationStatusNotDetermined) { - // Access has not been determined. requestAuthorization: is available - [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {}]; - - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + // Access has not been determined. requestAuthorization: is available, ask. + [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { + if (status == PHAuthorizationStatusAuthorized) { + NSLog(@"Access has been granted."); + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:true]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + } else if (status == PHAuthorizationStatusDenied) { + NSString* message = @"Access has been denied. Change your setting > this app > Photo enable"; + NSLog(@"%@", message); + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + } else if (status == PHAuthorizationStatusRestricted) { + NSString* message = @"Access has been restricted. Change your setting > Privacy > Photo enable"; + NSLog(@"%@", message); + + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + } + }]; } else if (status == PHAuthorizationStatusRestricted) { NSString* message = @"Access has been restricted. Change your setting > Privacy > Photo enable"; NSLog(@"%@", message);