Created
February 28, 2017 07:31
-
-
Save randhirraj3130/c95cab14bc502d8fd50959c6db425374 to your computer and use it in GitHub Desktop.
how to check PhotoLibraryPermission in swift 3.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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