From 113a931645562313ba8c4dbf1a343a6a8fa02ffb Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 25 May 2022 14:57:05 +1000 Subject: [PATCH] add access for selected photos permission --- .../ImagePickerController.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Session/Media Viewing & Editing/ImagePickerController.swift b/Session/Media Viewing & Editing/ImagePickerController.swift index 3500fdc99..233f78d53 100644 --- a/Session/Media Viewing & Editing/ImagePickerController.swift +++ b/Session/Media Viewing & Editing/ImagePickerController.swift @@ -92,6 +92,19 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat selectionPanGesture.delegate = self self.selectionPanGesture = selectionPanGesture collectionView.addGestureRecognizer(selectionPanGesture) + + if #available(iOS 14, *) { + if PHPhotoLibrary.authorizationStatus(for: .readWrite) == .limited { + let addSeletedPhotoButton = UIBarButtonItem.init(barButtonSystemItem: .add, target: self, action: #selector(addSelectedPhoto)) + self.navigationItem.rightBarButtonItem = addSeletedPhotoButton + } + } + } + + @objc func addSelectedPhoto(_ sender: Any) { + if #available(iOS 14, *) { + PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: self) + } } var selectionPanGesture: UIPanGestureRecognizer?