Reputation: 5244
I've hit "cancel" on a popup that asks permission for the photo library in the app I made. This comes from something I didn't make, but from the OS.
Now I need a fallback if the user tries to hit the photo library button again. The authorization status is denied. I proved by checking it this way:
let status = PHPhotoLibrary.authorizationStatus()
switch status {
case .authorized:
print("authorized")
case .denied:
print("denied") // it is denied
case .notDetermined:
print("notDetermined")
case .restricted:
print("restricted")
}
How do I present a popup asking for permission to the photo library again? I've looked everywhere and cannot find anything that works.
I was hoping it was something like this, but PHPhotoLibrary has no member "requestAccess":
PHPhotoLibrary.requestAccess(for: ???) { response in
if response {
//access granted
} else {
}
}
Upvotes: 1
Views: 7274
Reputation: 627
If the status be on . notDetermined
, so the app automatically shows the alert to the user, but if the status was on .restricted
or denied
you cannot do anything to ask user again for the access to the photos like the original one, but you can make a custom alert and ask user to give you access to the photos and if user accepted your request, lead the user to the setting and ask him to enable your access manually!
Upvotes: 6