App crashes with __CRASHING_DUE_TO_PRIVACY_VIOLATION__ when trying to access contacts
Asked Answered
R

7

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://mcmap.net/q/390857/-crash-on-xcode-8-0-gm-iphone-simulator-ios-10, but i couldn't find a guide of how to specify those usage descriptions in cordova.

Rabelaisian answered 19/9, 2016 at 11:2 Comment(2)
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.Hepta
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.Rabelaisian
R
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>
Rabelaisian answered 19/9, 2016 at 16:2 Comment(0)
H
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.

Hepta answered 19/9, 2016 at 11:52 Comment(5)
That did help, yes, what's left for me is to figure out how to manipulate that plist file from the Cordova config.Rabelaisian
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 "<ProductName>Info.plist" file.Hepta
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.Rabelaisian
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 meumobi.github.io/tips%20and%20tricks/2016/05/05/…Hepta
Yap, that's the route i'm takingRabelaisian
E
8

My app was missing NSFaceIDUsageDescription key

Eunuchize answered 7/5, 2018 at 10:33 Comment(1)
If you found this has only happened on iPhone X devices, then that's for sure it's missing NSFaceIDUsageDescription key in *info.plistUncommonly
R
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>
Rabelaisian answered 19/9, 2016 at 16:2 Comment(0)
P
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

Pippa answered 7/7, 2018 at 18:7 Comment(1)
you are right for my case, also I found the same explanation here ios.developreference.com/article/14888338/…Weslee
C
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

Commonweal answered 15/12, 2016 at 17:27 Comment(2)
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.Hepta
The was the answer for me after an upgrade for later iOS version, where before these were not required. Thanks for the heads up!Generative
B
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)

Barbosa answered 30/6, 2017 at 20:13 Comment(0)
H
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://mcmap.net/q/390858/-__crashing_due_to_privacy_violation__

Hautegaronne answered 5/2, 2020 at 10:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.