Skip to content

Commit

Permalink
Fix request photo auth method for iOS 14
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkRunWu committed Mar 31, 2021
1 parent 851f8f2 commit 25833a5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Sources/Controller/ImagePickerController+Closure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,23 @@ import Photos
}

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

0 comments on commit 25833a5

Please sign in to comment.