How do I check if a user was able to save to the camera roll during an activityViewController
?
For example, I have an activity view controller that offers the option to save to the camera roll. After the user saves the picture, my app displays a prompt letting the user know that the image was saved. However, when the users click on the "save to camera roll" icon, he gets prompted by the OS to give permissions so my app can store photos on their camera roll. If the user rejects the permission, the activityViewController.completionWithItemsHandler
still returns success, even thought the user didn't save the picture into the camera.
How can I check if the user was actually able to save the picture to the camera roll?
activityViewController.completionWithItemsHandler = { activity, success, items, error in
if success {
if let activity = activity {
switch activity {
case .postToFacebook:
self.view.showToast(with: "Successfully posted to Facebook.")
case .postToTwitter:
self.view.showToast(with: "Successfully posted to Twitter.")
case .message:
self.view.showToast(with: "Your message has been sent.")
case .mail:
self.view.showToast(with: "Your email has been sent.")
case .saveToCameraRoll:
if PHPhotoLibrary.authorizationStatus() == .denied {
self.view.show(alertForDeniedPermission(to: .photoLibraryAccess), animated: true)
} else {
self.view.showToast(with: "Your picture has been saved.")
}
default:
self.view.showToast(with: "Success!")
}
}
}
Checking for PHPhotoLibrary.authorizationStatus()
doesn't work since the enum is always . notDetermined
. I think because my app is only asking for Privacy - Photo Library Additions Usage Description
and not Privacy - Photo Library Usage Description
.