sparrowcode / PermissionsKit

Universal API for request permission and get its statuses.
https://x.com/sparrowcode_ios
MIT License
5.64k stars 462 forks source link

NSPhotoLibraryAddUsageDescription #126

Closed furiosFast closed 5 years ago

furiosFast commented 5 years ago

Hi, is NSPhotoLibraryAddUsageDescription supported?

ivanvorobei commented 5 years ago

Hi, yes

ivanvorobei commented 5 years ago

All sported permissions you can see here

furiosFast commented 5 years ago

where is he here?: https://github.com/ivanvorobei/SPPermission/blob/master/Source/SPPermission/SPPermissionType.swift

ivanvorobei commented 5 years ago

Hmmm Maybe this))

case .photoLibrary:
furiosFast commented 5 years ago

i've this: SPPermission.Dialog.request(with: [.locationWhenInUse, .notification, .photoLibrary/*, .microphone*/], on: viewController, delegate: self, dataSource: self) but che function SPPermission.isAllowed(.photoLibrary) return false always

ivanvorobei commented 5 years ago

I am now run example and all work correctly. You can send me simple example project for see? Or all code which you use.

furiosFast commented 5 years ago

i've this function in my app:

func simplePhotoViewerController(_ viewController: SimplePhotoViewerController, savePhotoAt index: Int) {
        guard let img = cartina.image else { return }
        UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil)
        //        share(UIButton())
        if SPPermission.isAllowed(.photoLibrary) {
            SCLAlertView(appearance: SCLAlertView.SCLAppearance(dynamicAnimatorActive: true)).showSuccess("", subTitle: loc("IMAGESAVE"))
        } else {
            let alert = SCLAlertView(appearance: SCLAlertView.SCLAppearance(dynamicAnimatorActive: false))
            alert.addButton(loc("settings_TITLEPAGE")) {
                UIApplication.shared.open(URL.init(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)
            }
            alert.showCustom(loc("permissionPREMISSIONDENIED"), subTitle: loc("permissionGOTO"), color: UIColor(hexString: "#0xFFD110"), closeButtonTitle: loc("permissionCANCEL"), colorTextButton: 0x000000, style: .warning)
        }
    }

and when i go to save the photo, if in setting app the photo permission for the app is set to "never", my app terminate with this error:

2019-07-29 21:21:00.057206+0200 This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data.

if i add the property NSPhotoLibraryAddUsageDescription in the info.plist, and i set from ios settings app the photo permission on "Add photo only", the function SPPermission.isAllowed(.photoLibrary) return false

ivanvorobei commented 5 years ago

How you request permission?

furiosFast commented 5 years ago
func presentPermissonDialogFromWelcomeView(_ viewController: UIViewController) {
        SPPermission.Dialog.request(with: [.locationWhenInUse, .notification, .photoLibrary/*, .microphone*/], on: viewController, delegate: self, dataSource: self)
    }
furiosFast commented 5 years ago

Is this the case with the authorization .restricted?

ivanvorobei commented 5 years ago

What is case Add photo only? In permission state has only this.

Screenshot 2019-07-29 at 22 30 04

I am try using your code - all work correct. When you call simplePhotoViewerController? After request permission? Show code.

furiosFast commented 5 years ago

now set the permission to "never" and try to call this lines of code with a button:

guard let img = imageView.image else { return }
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil)
ivanvorobei commented 5 years ago

It code not should work. Never state restricted permission to Photo Lubrary.

furiosFast commented 5 years ago

What is case Add photo only? In permission state has only this.

Screenshot 2019-07-29 at 22 30 04

I am try using your code - all work correct. When you call simplePhotoViewerController? After request permission? Show code.

Yes, i request permission at the first launch of my app

ivanvorobei commented 5 years ago

If you deny access to the Photo Library (set Never state), of course the function isAllow will return false.

ivanvorobei commented 5 years ago

Also function UIImageWriteToSavedPhotosAlbum complete, but with error in completion.

furiosFast commented 5 years ago

if you set to "never" the permission and try again to save the photo, the app crash with this error:

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data.

ivanvorobei commented 5 years ago

if you set to "never" the permission and try again to save the photo, the app crash with this error:

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data.

My library is not responsible for this.

ivanvorobei commented 5 years ago

So one sec I found this

NSPhotoLibrary - ADD - UsageDescription

furiosFast commented 5 years ago

yes, NSPhotoLibraryAddUsageDescription

ivanvorobei commented 5 years ago
Screenshot 2019-07-29 at 22 41 47

I am use NSPhotoLibraryUsageDescription for both, all ok.

As I understand it, when you change the permission in the settings, do you get an error when saving? But my library does not participate in these actions, you need to look for another reason.

furiosFast commented 5 years ago

OK thanks

ivanvorobei commented 5 years ago

Also I am record video - all changes see correctly. Add only NSPhotoLibraryUsageDescription. Screen Recording 2019-07-29 at 22.45.20.zip

furiosFast commented 5 years ago

thanks again!!