Skip to content

Commit

Permalink
Fix photo permission request not response once user cancel it
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkRunWu committed Mar 31, 2021
1 parent 8d4ce61 commit dc7ef14
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions Sources/Controller/ImagePickerController+Closure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,35 @@ import Photos

private func authorize(_ authorized: @escaping () -> Void) {
if #available(iOS 14, *) {
PHPhotoLibrary.requestAuthorization(for: .readWrite) { (status) in
switch status {
case .authorized,
.limited:
DispatchQueue.main.async(execute: authorized)
default:
break
let immediateStatus = PHPhotoLibrary.authorizationStatus(for: .readWrite)
switch immediateStatus {
case .authorized,
.limited:
DispatchQueue.main.async(execute: authorized)
default:
PHPhotoLibrary.requestAuthorization(for: .readWrite) { (status) in
switch status {
case .authorized,
.limited:
DispatchQueue.main.async(execute: authorized)
default:
break
}
}
}
} else {
PHPhotoLibrary.requestAuthorization { (status) in
switch status {
case .authorized:
DispatchQueue.main.async(execute: authorized)
default:
break
let immediateStatus = PHPhotoLibrary.authorizationStatus()
switch immediateStatus {
case .authorized:
DispatchQueue.main.async(execute: authorized)
default:
PHPhotoLibrary.requestAuthorization { (status) in
switch status {
case .authorized:
DispatchQueue.main.async(execute: authorized)
default:
break
}
}
}
}
Expand Down

0 comments on commit dc7ef14

Please sign in to comment.