[Solution] Fix iOS 10 Privacy Permissions

So since iOS10, if you don’t have permission descriptions set in your .plist config, when trying to access camera (among other things) your ionic1 app will crash on certain devices (iPhone 6s is one of them)

Solution

I’m adding this so other people can avoid the same frustration I did.

First, the issue is that you’re missing Privacy properties in your info.plist file. These are description properties for why your app needs to access certain things. If they don’t exist, they can crash your app on some devices.

To solve this you just need to add the relevant ones you want. You can find the list of properties you can use / may need here.

You can do this manually or you can make use of the cordova-custom-config plugin. This allows you to create platform specific config settings in your config.xml that then get written to the .plist AFTER build automatically.

For example:

<platform name="ios">
    <config-file parent="NSPhotoLibraryUsageDescription" platform="ios" target="*-Info.plist">
      <string>This app needs access to your Photo Library for uploading files</string>
    </config-file>
    <config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist">
      <string>This app needs access to your Camera to allow you to take and upload a picture.</string>
    </config-file>

This then writes the properties into your info.plist for you automatically resulting in:

<key>NSPhotoLibraryUsageDescription</key>
    <string>This app needs access to your Photo Library for uploading files</string>
    <key>NSCameraUsageDescription</key>
    <string>This app needs access to your Camera to allow you to take and upload a picture.</string>
  </dict>
</plist>

Hope that helps :slight_smile:

3 Likes

This is the best solution I have found. Thank you very much! Save me a lot of pain…

You’re welcome :). Know how much of a pain it was for me to find a decent solution myself.

another easy solution for this method check out this link
it may help you to solve this
https://www.npmjs.com/package/cordova-plugin-ios-camera-permissions

i add same code on my config.xml and my info.plist file but device not asking me permission for accessing photos or files from storage.

here is my info.plist file keys that i used

<key>NSBluetoothAlwaysUsageDescription</key>
	<string>This app requires constant Bluetooth access to function properly.</string>
	<key>NSBluetoothPeripheralUsageDescription</key>
	<string>This app requires Bluetooth access to function properly.</string>
	<key>NSCalendarsUsageDescription</key>
	<string>This app requires calendar access to function properly.</string>
	<key>NSCameraUsageDescription</key>
	<string>This app requires camera access to function properly.</string>
	<key>NSContactsUsageDescription</key>
	<string>This app requires contacts access to function properly.</string>
	<key>NSDesktopFolderUsageDescription</key>
	<string>This app needs access to folder to allow you to take and upload a picture.</string>
	<key>NSDocumentsFolderUsageDescription</key>
	<string>This app needs access to folder to allow you to take and upload a picture.</string>
	<key>NSDownloadsFolderUsageDescription</key>
	<string>This app needs access to folder to allow you to take and upload a picture.</string>
	<key>NSFileProviderDomainUsageDescription</key>
	<string>This app needs access to folder to allow you to take and upload a picture.</string>
	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
	<string>This app requires constant access to your location in order to track your position, even when the screen is off or the app is in the background.</string>
	<key>NSLocationAlwaysUsageDescription</key>
	<string>This app requires constant access to your location in order to track your position, even when the screen is off or the app is in the background.</string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>This app requires access to your location when the screen is on and the app is displayed.</string>
	<key>NSMainNibFile</key>
	<string></string>
	<key>NSMainNibFile~ipad</key>
	<string></string>
	<key>NSMicrophoneUsageDescription</key>
	<string>This app requires microphone access to function properly.</string>
	<key>NSMotionUsageDescription</key>
	<string>This app requires motion detection access to function properly.</string>
	<key>NSPhotoLibraryAddUsageDescription</key>
	<string>App require permission for access photos</string>
	<key>NSPhotoLibraryUsageDescription</key>
	<string>To choose photos</string>
	<key>NSRemindersUsageDescription</key>
	<string>This app requires reminders access to function properly.</string>

and i also add it to config.xml file

<config-file parent="NSPhotoLibraryUsageDescription" platform="ios" target="*-Info.plist">
            <string>This app requires photo library access to function properly.</string>
        </config-file>
        <config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist">
            <string>This app needs access to your Camera to allow you to take and upload a picture.</string>
        </config-file>
        <config-file parent="NSPhotoLibraryAddUsageDescription" platform="ios" target="*-Info.plist">
            <string>This app needs access to your Camera to allow you to take and upload a picture.</string>
        </config-file>
        <config-file parent="NSDesktopFolderUsageDescription" platform="ios" target="*-Info.plist">
            <string>This app needs access to folder to allow you to take and upload a picture.</string>
        </config-file>
        <config-file parent="NSDocumentsFolderUsageDescription" platform="ios" target="*-Info.plist">
            <string>This app needs access to folder to allow you to take and upload a picture.</string>
        </config-file>
        <config-file parent="NSDownloadsFolderUsageDescription" platform="ios" target="*-Info.plist">
            <string>This app needs access to folder to allow you to take and upload a picture.</string>
        </config-file>
        <config-file parent="NSFileProviderDomainUsageDescription" platform="ios" target="*-Info.plist">
            <string>This app needs access to folder to allow you to take and upload a picture.</string>
        </config-file>