What's difference between NSPhotoLibraryAddUsageDescription and NSPhotoLibraryUsageDescription?
Solution 1
To answer the last question on my own:
You need to declare both NSPhotoLibraryUsageDescription
and NSPhotoLibraryAddUsageDescription
to get it WORKS on both iOS 9, 10.3 and 11.
Technically it's different.
I used to not declare NSPhotoLibraryUsageDescription
, it works fine on iOS 9 and 11 but failed and crashed on iOS 10.3.
This is a really bad version controlling from Apple while higher version doesn't comply and support older version permission.
Solution 2
Simple get from Apple Official Document
Just click on above image for ZOOM and read it.
For more information on:
NSPhotoLibraryAddUsageDescription: If you want to save a photo/image to your Photo Library. For
iOS11 and +
NSPhotoLibraryUsageDescription: If you want to access your Photo Library. For
iOS10 and +
Solution 3
As I can see in the document, the difference between two is:
NSPhotoLibraryAddUsageDescription: You have permission to write only, no read.
NSPhotoLibraryUsageDescription: You can both read and write to Photos.
From Apple documentations for NSPhotoLibraryUsageDescription:
"Although this keys governs read and write access to the user’s photo library, it’s best to use NSPhotoLibraryAddUsageDescription if your app needs only to add assets to the library and does not need to read any assets."
Solution 4
There is a difference for write access based on the API asking for permission as well as the iOS version, so you need both.
My app already had NSPhotoLibraryUsageDescription in order to use PHPhotoLibrary to save images.
On iOS 11, that still works but if my app hasn't yet got permission then sharing an image via "Save Image" in a UIDocumentInteractionController causes a crash with a warning about NSPhotoLibraryAddUsageDescription. If permission has already been granted via PHPhotoLibrary I don't seem to need NSPhotoLibraryAddUsageDescription for "Save Image".
Solution 5
You gonna need both.
Because once I tried use UIActivityViewController
to save image to library, my iphone version is 11.3, I only use NSPhotoLibraryUsageDescription
and it's crash because i need NSPhotoLibraryAddUsageDescription
.
But ios 9.3 not crash.
TomSawyer
Updated on July 07, 2022Comments
-
TomSawyer almost 2 years
My app get crashed today while updating on Xcode9, testing on iOS11. After adding
NSPhotoLibraryAddUsageDescription
then it works, even i already hadNSPhotoLibraryUsageDescription
.Ive read about them, one supported since iOS6, one iOS11 but Apple didn't mention what's difference between them. https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW73
If i keep the new one (
NSPhotoLibraryAddUsageDescription
), will it work for iOS 8 also or i have to keep both of them? -
TomSawyer almost 7 yearsI've read it, it didn't tell anything, please answer my questions above. Both give read and write access, what's diffrence between them, which one should i keep for get both ios version supporting
-
Govaadiyo almost 7 yearsDid you see my screenshot ? If you want to add photo/image in library then you must need to add NSPhotoLibraryAddUsageDescription in your info.plist
-
TomSawyer almost 7 years
NSPhotoLibraryUsageDescription
can do it too, since iOS 6.Although this keys governs read and write access to the user’s photo library,
-
dmorrow almost 7 yearsIt's unclear how to trigger the dialog for
NSPhotoLibraryAddUsageDescription
- however its definitely crashing apps without it. -
Tien almost 7 yearsCould you try to call UIImageWriteToSavedPhotosAlbum ?
-
dmorrow almost 7 yearsUsing
PHPhotoLibrary.requestAuthorization()
seems to work - just not clear which key is being used. -
Tien almost 7 yearsPHPhotoLibrary.requestAuthorization() will ask you for NSPhotoLibraryUsageDescription. If you deny on that dialog and you call UIImageWriteToSavedPhotosAlbum, dialog for NSPhotoLibraryAddUsageDescription will appear.
-
dmorrow almost 7 yearsThen what method do you call to check that it is safe to call
UIImageWriteToSavedPhotosAlbum
? -
Roi Mulia over 5 yearsDid you find out to monitor the permission for NSPhotoLibraryAddUsageDescription? Seems like it only return results for NSPhotoLibraryUsageDescription