try to handle limited photo permission
This commit is contained in:
parent
a48a5ac847
commit
df1b4fda57
|
@ -1,5 +1,6 @@
|
|||
import CoreServices
|
||||
import Photos
|
||||
import PhotosUI
|
||||
|
||||
extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuActionDelegate, ScrollToBottomButtonDelegate,
|
||||
SendMediaNavDelegate, UIDocumentPickerDelegate, AttachmentApprovalViewControllerDelegate, GifPickerViewControllerDelegate,
|
||||
|
@ -727,7 +728,34 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
}
|
||||
|
||||
func requestLibraryPermissionIfNeeded() -> Bool {
|
||||
switch PHPhotoLibrary.authorizationStatus() {
|
||||
let authorizationStatus: PHAuthorizationStatus
|
||||
if #available(iOS 14, *) {
|
||||
authorizationStatus = PHPhotoLibrary.authorizationStatus(for: .readWrite)
|
||||
if (authorizationStatus == .notDetermined) {
|
||||
PHPhotoLibrary.requestAuthorization(for: .readWrite) { newStatus in
|
||||
switch newStatus {
|
||||
case .authorized:
|
||||
print("RYAN: Full access.")
|
||||
break
|
||||
case .limited:
|
||||
print("RYAN: Limited access.")
|
||||
break
|
||||
case .denied:
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
authorizationStatus = PHPhotoLibrary.authorizationStatus()
|
||||
if (authorizationStatus == .notDetermined) {
|
||||
PHPhotoLibrary.requestAuthorization { _ in }
|
||||
return false
|
||||
}
|
||||
}
|
||||
switch authorizationStatus {
|
||||
case .authorized, .limited: return true
|
||||
case .denied, .restricted:
|
||||
let modal = PermissionMissingModal(permission: "library") { }
|
||||
|
@ -735,9 +763,6 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
modal.modalTransitionStyle = .crossDissolve
|
||||
present(modal, animated: true, completion: nil)
|
||||
return false
|
||||
case .notDetermined:
|
||||
PHPhotoLibrary.requestAuthorization { _ in }
|
||||
return false
|
||||
default: return false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PHPhotoLibraryPreventAutomaticLimitedAccessAlert</key>
|
||||
<true/>
|
||||
<key>BuildDetails</key>
|
||||
<dict>
|
||||
<key>CarthageVersion</key>
|
||||
|
@ -59,7 +61,7 @@
|
|||
<key>NSContactsUsageDescription</key>
|
||||
<string>Signal uses your contacts to find users you know. We do not store your contacts on the server.</string>
|
||||
<key>NSFaceIDUsageDescription</key>
|
||||
<string>Session's Screen Lock feature uses Face ID.</string>
|
||||
<string>Session's Screen Lock feature uses Face ID.</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>Session needs access to your microphone to record media.</string>
|
||||
<key>NSPhotoLibraryAddUsageDescription</key>
|
||||
|
|
Loading…
Reference in New Issue