Reputation: 23
I want to save images in to the ios camera roll. It works well in the simulator.
but on the actual iPhone I don't get a permission prompt like this:
- (void)saveImageToCameraRoll:(CDVInvokedUrlCommand*)command
{
CDVPluginResult* pluginResult = nil;
NSString *filename = [command argumentAtIndex:0];
NSString *tmpFile = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", filename]];
UIImage *image = nil;
image = [UIImage imageWithContentsOfFile:tmpFile];
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
if(status != ALAuthorizationStatusAuthorized || image == nil){
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"noaccess"];
}
else{
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"saved"];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
is there any way to force it?
Thanks. Cheers.
Upvotes: 0
Views: 2001
Reputation: 1143
iOS asks for the permission only once. Even if you reinstall the app, the permission will not be asked again, it will just use the old preference.
To force iOS to ask for permission, uninstall your application and change the date few days ahead and install it back. You will see the security prompt again.
Upvotes: 1
Reputation: 392
Once a user allows there permission for it, iOS won't ask for the same permission permission next time again unless you uninstall and install again.
Or if you want to check for the permissions go to settings and see whether your app has Photo's permission turned on.
Upvotes: 0
Reputation: 801
If you rejected the permission then, you can't get the prompt by forcing it. You can check whether you've access and not. If you don't have access then you can ask the user to give permission in settings app against your app..
Like this.
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
if (status != ALAuthorizationStatusAuthorized) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Attention" message:@"Please give this app permission to access your photo library in your settings app!" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil, nil];
[alert show];
}
Upvotes: 2