43

Upon updating to iOS 10, when trying to access the contacts through plugin cordova-plugin-contacts v2.2.0, the app exits with

__CRASHING_DUE_TO_PRIVACY_VIOLATION__

I don't know what other extra info i can provide right now, just let me know if i can be more specific. Thanx.

Maybe this is of some use: https://stackoverflow.com/a/39416858/592641, but i couldn't find a guide of how to specify those usage descriptions in cordova.

Community
  • 1
  • 1
Daniel Birowsky Popeski
  • 8,752
  • 12
  • 60
  • 125
  • Did you create an xcode project ? Find a `Info.Plist` file using `Navigator` (the left panel of xcode), add the entry in plist file you found in the link of your own question. Once done install a fresh copy. – NeverHopeless Sep 19 '16 at 11:31
  • Found it, now, what is the exact key/string combo that i need to use for contacts? The combo in the link is about camera. – Daniel Birowsky Popeski Sep 19 '16 at 11:43

7 Answers7

35

After creating an Xcode project and finding the Info.Plist file, you may try adding NSContactsUsageDescription key, which should accept a string value.

A complete list of Cocoa Keys

Hope that helps!

EDIT

A part from the doc: (which can help you understand why it is crashing)

Important: To protect user privacy, an iOS app linked on or after iOS 10.0, and which accesses the user’s contacts, must statically declare the intent to do so. Include the NSContactsUsageDescription key in your app’s Info.plist file and provide a purpose string for this key. If your app attempts to access the user’s contacts without a corresponding purpose string, your app exits.

shim
  • 9,289
  • 12
  • 69
  • 108
NeverHopeless
  • 11,077
  • 4
  • 35
  • 56
  • That did help, yes, what's left for me is to figure out how to manipulate that plist file from the Cordova config. – Daniel Birowsky Popeski Sep 19 '16 at 11:59
  • Once you added the entry in "Info.Plist", system should read this entry from plist itself during execution, you don't have to (un)load this plist file. When from the code a request to such permission based services initiates it looks for the usage description in the "Info.plist" file. – NeverHopeless Sep 19 '16 at 12:04
  • Of course, but the problem is that all these platform-specific files are being generated from the Cordova config. Hence, they are not part of the VCS. So I must specify these changes explicitly in the Cordova config in order for them to be generated everywhere. – Daniel Birowsky Popeski Sep 19 '16 at 12:08
  • I don't think so there is a direct way, as while i was working with unity and later port it to xcode, few manual steps before deployment was needed. I found this through google `http://stackoverflow.com/questions/22769111/add-entry-to-ios-plist-file-via-cordova-config-xml` which says writing and installing a plugin can do this job. Another example for writing a plugin http://meumobi.github.io/tips%20and%20tricks/2016/05/05/add-entry-ios-plist-cordova.html – NeverHopeless Sep 19 '16 at 12:24
  • Yap, that's the route i'm taking – Daniel Birowsky Popeski Sep 19 '16 at 12:27
8

My app was missing NSFaceIDUsageDescription key

  • 1
    If you found this has only happened on iPhone X devices, then that's for sure it's missing `NSFaceIDUsageDescription` key in `*info.plist` – Chao Ruan Jun 07 '18 at 22:50
6

In short, the usage descriptions need to be specified inside *info.plist

That's no good for Cordova codebase since .plist files are not part of the repository. The simplest way I found to put them inside config.xml is this:

  1. Install cordova-custom-config
  2. Add the following inside config.xml:

.

<platform name="ios">
    <config-file parent="NSContactsUsageDescription" target="*info.plist">
      <string>Easily invite your friends</string>
    </config-file>
</platform>
Daniel Birowsky Popeski
  • 8,752
  • 12
  • 60
  • 125
6

My Info.plist was missing NSPhotoLibraryAddUsageDescription. There are now TWO permissions associated with the photo library (starting iOS 11):

  • NSPhotoLibraryUsageDescription - to access the photo library
  • NSPhotoLibraryAddUsageDescription - write only permission to photo library

I had the first permission prior to iOS 11 when it was the only key needed to use the photo library. Apparently in iOS 11 they added the second and made it required to add photos to the library. So if you support iOS 10 but don't include the second key, you will crash on iOS 11.

All Keys are Here

Cliff Ribaudo
  • 8,932
  • 2
  • 55
  • 78
  • you are right for my case, also I found the same explanation here https://ios.developreference.com/article/14888338/Identifying+privacy+violation+in+iOS+10 – Gomer Grek Apr 24 '20 at 16:43
4

For me, I was trying to request access to the microphone, but I hadn't defined the Privacy - Microphone Usage Description string.

Go into your Info.plist file, and scroll down to the values that start with Privacy. Make sure you add keys and string values for everything relevant to your app.

Screenshot of the values that start with Privacy in the info.plist

Chase Roberts
  • 9,082
  • 13
  • 73
  • 131
  • Have you tried adding "NSMicrophoneUsageDescription" as a microphone usage description key in your plist ? You can find this in the link added in my answer. – NeverHopeless Dec 20 '16 at 12:58
  • The was the answer for me after an upgrade for later iOS version, where before these were not required. Thanks for the heads up! – DBrown Feb 19 '20 at 20:47
1

I got here with the same error using Kudan AR via Unity, and @NeverHelpless's answer was on target, except the fix was NSCameraUsageDescription (Add to Info.plist with a description string)

gravy
  • 181
  • 2
  • 8
0

If you are clear the issue is when accessing Contacts, then follow instructions posted on above answers.

But if those didn't help you, you may want to read my related answer here on other possible solutions (if you are using Bluetooth on your app): https://stackoverflow.com/a/60073667/457202

Juan Fran Jimenez
  • 1,629
  • 15
  • 19