Skip to content

Instantly share code, notes, and snippets.

@randhirraj3130
Created February 28, 2017 07:31
Show Gist options
  • Save randhirraj3130/c95cab14bc502d8fd50959c6db425374 to your computer and use it in GitHub Desktop.
Save randhirraj3130/c95cab14bc502d8fd50959c6db425374 to your computer and use it in GitHub Desktop.
how to check PhotoLibraryPermission in swift 3.0
func checkPhotoLibraryPermission() {
let status = PHPhotoLibrary.authorizationStatus()
switch status {
case .authorized:
self.GetGalleryImage()
break
//handle authorized status
case .denied, .restricted : break
//handle denied status
case .notDetermined:
// ask for permissions
PHPhotoLibrary.requestAuthorization() { status in
switch status {
case .authorized:
self.GetGalleryImage()
break
// as above
case .denied, .restricted: break
// as above
case .notDetermined: break
// won't happen but still
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment