0
class func checkPhotoLibraryPermission() {
        // TODO: @Umer Complete this process as discussed
        let photoAuthorizationStatus = PHPhotoLibrary.authorizationStatus()
        switch photoAuthorizationStatus {
        case .authorized:
            print("Access is granted by user")
        case .notDetermined:
            PHPhotoLibrary.requestAuthorization({
                (newStatus) in
                print("status is \(newStatus)")
                if newStatus ==  PHAuthorizationStatus.authorized {
                    /* do stuff here */
                    print("success")
                }
                else {
                }
            })
            print("It is not determined until now")
        case .restricted:
            print("User do not have access to photo album.")
        case .denied:
            print("User has denied the permission.")
        }
    }

in case .denied If we come first time to access photo library access permission is asked to user and if user do not allow permission, next time when user tries to access photo library it directly goes to settings where user can manually set permissions.

Laurent Mouchart
  • 216
  • 1
  • 3
  • 13
Sofia
  • 11
  • 1
  • 5
    Possible duplicate of [How do i open phone settings when a button is clicked ios](https://stackoverflow.com/questions/28152526/how-do-i-open-phone-settings-when-a-button-is-clicked-ios) – Tamás Sengel Apr 25 '18 at 10:42
  • try this code: UIApplication.shared.open(URL(string:UIApplicationOpenSettingsURLString)!) – Moayad Al kouz Apr 25 '18 at 11:16

0 Answers0