Dimillian / IceCubesApp

A SwiftUI Mastodon client
https://apps.apple.com/us/app/ice-cubes-for-mastodon/id6444915884
GNU Affero General Public License v3.0
5.56k stars 539 forks source link

MediaUIView - Fix image download bug (#2131) #2215

Open Taufi opened 4 weeks ago

Taufi commented 4 weeks ago

If the user has not yet granted permission to download photos, they will be asked to do so: PHPhotoLibrary.requestAuthorization(for: .addOnly). Afterward, the photos can also be downloaded to the desktop. Previously, broader access was granted (requestAuthorization(_:)), but this method is now deprecated. Apparently, Mac Catalyst support for more advanced permission checks is still not fully developed. Once permission is denied, it can no longer be granted in the settings. You have to do it via a terminal command: 'tccutil reset PhotosAdd <your.app.bundle.identifier>'.

Taufi commented 1 week ago

I worked on improving the PR based on the reviewers' recommendations:

First, I updated the saveImage(url:) function in MediaUIView.swift as recommended by D. Prodano. I kept the second if clause to initiate the image download immediately after requesting authorization. I can change this if preferred, but it would then require the user to manually restart the download after granting authorization.

Additionally, I added the NSPhotoLibraryAddUsageDescription, following Ankush's recommendation.