diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index a18f369f3..0560a7652 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -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 } } diff --git a/Session/Meta/Session-Info.plist b/Session/Meta/Session-Info.plist index e05788065..e276c43a5 100644 --- a/Session/Meta/Session-Info.plist +++ b/Session/Meta/Session-Info.plist @@ -2,6 +2,8 @@ + PHPhotoLibraryPreventAutomaticLimitedAccessAlert + BuildDetails CarthageVersion @@ -59,7 +61,7 @@ NSContactsUsageDescription Signal uses your contacts to find users you know. We do not store your contacts on the server. NSFaceIDUsageDescription - Session's Screen Lock feature uses Face ID. + Session's Screen Lock feature uses Face ID. NSMicrophoneUsageDescription Session needs access to your microphone to record media. NSPhotoLibraryAddUsageDescription