Reputation: 2817
I am checking camera and photo permission on my App when user select or capture any image. I am using this code.
-(void)choosePhotoFromExistingImages
{
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
if (status == ALAuthorizationStatusDenied || status == ALAuthorizationStatusRestricted) {
[APPDELEGATE showAlertViewForPhotos];
//show alert for asking the user to give permission
}
else{
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
controller.allowsEditing = YES;
controller.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil] ;
controller.delegate = self;
[self presentViewController: controller animated: YES completion: nil];
}
}
}
The code is working fine but when user first time choose Don't allow photo library it display a black screen like this same thing happening in camera.
What i need is that when user press on don't allow i can check that user has cancel the permission so i can dismiss imagepicker or camera .
Upvotes: 1
Views: 1450
Reputation: 1365
You can use ALAssetsLibrary authorizationStatus
to check it
How do I react to a user choosing "Don't Allow" when asking for permission to access Photos?
Upvotes: 3