iOS 10 Save to Camera Roll Bug/Crash - ios

When trying to save an image to camera roll in iOS10 using
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
the app crashes without any information. Same exact method does not cause crash on iOS 9 devices

Add Below permission in Info.plist
<key>NSCameraUsageDescription</key>
<string>This app needs access to the camera to take photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to photos.</string>
More info Click here

Edit you Info.plist
You need to add these line in the plist.
It will crash too if you're using camera. In case of this, I put the solutions here.
If you're using camera, you just need to add the first line.
If you're just using saving photo to local album, you only need to add the second line.
You can change the description to what you wanna claim. It shows in iOS Camera/Photo alertView to get user's permissoin.

This was kind of a sneaky update (I didn't hear about this at least), but for iOS10 there are new required Info.plist files for requiring access to assets such as Photos (which causes the crash in this case). Take a read here
http://useyourloaf.com/blog/privacy-settings-in-ios-10/
But for solving this specific problem, just this to your Info.plist source code:
<key>NSPhotoLibraryUsageDescription</key>
<string>Reason why you need the permissions here</string>

Related

flutter iOS app crashes when trying to upload image using camera inside Webview

I am creating a flutter app using webview_flutter plugin, everything is working fine. In the website, there is a form in which users can upload images(that asks to choose weather to use Camera or Album to choose image). When I tap on Camera the app crashes.
Are you using the latest version of webview_flutter? I did a flutter pub upgrade and added
<key>NSCameraUsageDescription</key>
<string>Add image to profile</string>
to ios/Runner/Info.plist.
Crashes happen because your app needs to request a permission from user to access camera or photos library (depending on what user picks). But in order to make such request you need to provide a message with description on why do you need this permission. Such description should be added into Info.plist file located in ios/Runner folder of the project.
For the case you described with picking image from camera or photos library you need to add the following 2 keys with descriptions:
<key>NSCameraUsageDescription</key>
<string>Your description on why app needs access to camera</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Your description on why app needs access to photos library</string>
Here is information about mentioned keys in the official docs:
https://developer.apple.com/documentation/bundleresources/information_property_list/nscamerausagedescription
https://developer.apple.com/documentation/bundleresources/information_property_list/nsphotolibraryusagedescription
One more case with webview when you would need to have NSPhotoLibraryUsageDescription or NSPhotoLibraryAddUsageDescription in project's Info.plist file is to avoid crashes when user tries to download image via Save to photos context menu item. Such context menu appears when user long presses on some image on a web page.
The difference between 2 keys above is in fact that NSPhotoLibraryAddUsageDescription allows your app to only write (download) images to photos library, not read them, so it is more preferable way if you only want to let image downloads.
Here is info about this key: https://developer.apple.com/documentation/bundleresources/information_property_list/nsphotolibraryaddusagedescription

iOS - Disable "Take Photo or Video"

I have created a Cordova app, but in-app browser, but the problem is with the "Take Photo or Video" feature.
If you want to upload an image from a camera device, the app crashes.
My idea is, how to disable that feature?
I don't want (If it is not necessary) to install camera device support from Cordova or the same... Thank you!
Use this in info.plist file. This fix 'take photo', or problem with video will be stay
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo Library Access Warning</string>

Is it mandatory to add NSPhotoLibraryUsageDescription in info.plist?

I am not using UIImagePicker in my app and not accessing the Photo Library. I got a mail regarding add NSPhotoLibraryUsageDescription in info.plist file.
I have following questions
How to confirm my project accessing the photo library?
I already searched UIImagePicker in my project and did't get any result.
Is it mandatory to add NSPhotoLibraryUsageDescription in info.plist while i am not accessing the photo library?
Can any one help to find it out .
Thanks
UIImagePicker
An image picker controller manages user interactions and delivers the results of those interactions to a delegate object. The role and appearance of an image picker controller depend on the source type you assign to it before you present it.
whenever you used UIImagePicker, you have to give permission for that particular application
There is a list of all Cocoa Keys that you can specify in your Info.plist file:
https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html
(Xcode target -> Info -> Custom iOS Target Properties)
iOS already required permissions to access microphone, camera, and media library earlier (iOS6, iOS7), but since iOS10 the apps will crash if you don't provide the description why you are asking for the permission.
UPDATE:
Summary of all privacy keys (with example description):
Useful Link
You only have to add this key-value pair to your info.plist if you are actually accessing the photos any way. If it's not added the app is going to crash.
Check if any of your added dependencies using UIImagePicker.
No it's not mandatory to add NSPhotoLibraryUsageDescription key in info.plist. If your App is not using accessing photo from library/gallery then you should remove it. But as "#Bence Pattogato" said if Your app accessing photo from library/gallery and there is no key added in info.plist then it will be crash.
For your information below are different keys that required to add info.plist if you accessing relevant features according to camera/photo library.
1) NSPhotoLibraryUsageDescription : This key lets you describe the reason your app accesses the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.
2) NSCameraUsageDescription : describes the reason that the app (including an iMessage app) accesses the device’s camera. When the system prompts the user to allow access, this string is displayed as part of the alert.
3) NSPhotoLibraryAddUsageDescription : (New in iOS 11) This key lets you describe the reason your app seeks write-only access to the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.
Above information get from this Appel official link.

Xcode: Missing Info.plist key for NSCameraUsageDescription

After adding GPUImage to my Xcode project, my app is getting denied for Missing an Info.plist key for NSCameraUsageDescription.
Missing Info.plist key - This app attempts to access privacy-sensitive
data without a usage description. The app's Info.plist must contain an
NSCameraUsageDescription key with a string value explaining to the
user how the app uses this data.
I have added the key and description to my plist in several different ways and over 10 builds have all gotten the same denial error.
Here is my info.plist with the Camera Usage key at the bottom.
Any ideas on why I still get denied when I clearly have this defined in my plist?
You need to put a particular and proper description to use Camera in your application. One my application is denied due to improper description. So try with a proper description, maybe it will help you.
<key>Privacy - Camera Usage Description</key>
<string>APPNAME requires access to your phone’s camera.</string>
Ok it is an old one but i'd share my experience... nothing was working for me.
What i add to to was :
using Xcode to edit the plist.info. NOT in an external editor !!!!
DO NOT edit the text CREATE a new key using the + sign.
it will ask you to replace the previous (unless the previous one has been entered wrong... my case i think)
Try the both Camera and Library permission in Plist.
<key>NSCameraUsageDescription</key>
<string>Access camera</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Library</string>
I know this is an older post, but for me, it took an hour to discover that I was not editing the correct Info.plist file, but the one for UI Tests. Double-check which one you are editing, it can be the cause.
You should enter the purpose of using camera as the description. If it does not give the purpose app will get rejected.
you should add something like
Appname requires to access camera for taking profile picture or Appname requires to access camera for uploading product images
From the apple: Check this link.
To protect user privacy, an iOS app linked on or after iOS 10.0, and
that accesses the device’s camera, must statically declare the intent
to do so. Include the NSCameraUsageDescription key in your app’s
Info.plist file and provide a purpose string for this key. If your app
attempts to access the device’s camera without a corresponding purpose
string, your app exits.
I got the same error as OP. I don't know why though because I wasn't using anything related to the camera in my app. So I included this as the description and worked.
"AppName does not use the camera to capture to take a profile picture or upload profile photos."
GPUImage is for capturing image and video, i guess adding Microphone permission might solve the issue
<key>NSCameraUsageDescription</key>
<string>Need to access your camera to capture a picture and record a video.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Need to access your microphone to record a video.</string>
try!
<key>NSCameraUsageDescription</key>
<string>Need to access your camera to capture a photo add and update profile picture.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Need to access your photo library to select a photo add and update profile picture</string>
I have the same problem even I add the privacy-Camera Usage Description in the info.plist. I try to clean and rebuild the project. Reopen the Xcode. Everything doesn't work until I add the privacy-Camera Usage Description in the Custom ios Target Properties. Hope it solve your problem.
For app store submission, The Usage description should briefly explain why we really needs that feature.
Description:
Camera Use
is too short and doesn't explains why we actually need camera.
It should be something like:
App Needs to use camera to take Profile picture
If you write
Privacy - Camera Usage Description,
change to
NSCameraUsageDescription
you have to put accurate condition in front of any policy, "camera use" is wrong
here, and for this specific problem you have to put "AVCaptureDeviceInput" in front of privacy. Hope it will work for you.
For more you can go to this link and check other privacy policy as well.
https://developer.apple.com/library/content/qa/qa1937/_index.html
let me know about the result.
Try the following things:
Delete deriveddata
Make sure you are not editing the ones in test folders.
Increase development ios version to 11.0

Application can't load photos from Photo Library on iOS simulator

I am facing problem in loading photos on simulator but it is working on devices. Even it is working on other mac. I have added the NSPhotoLibraryUsageDescription key into the plist file. But the permission message is not loading while I am going to access the photo library.
Instead I am getting the following scenario on simulator:
I have also checked the settings on simulator and my app is not showing on Photos privacy:
You need to add permission
Please read this link to load photos in iOS 10
https://iosdevcenters.blogspot.com/2016/09/infoplist-privacy-settings-in-ios-10.html
You need to give permission to your app to access photos. For this you need to do following steps:
Open settings in your simulator
Look for your App name and then tap on it.
Then turn on the switch to access photo's.

Resources