App crashes with __CRASHING_DUE_TO_PRIVACY_VIOLATION__ when trying to access contacts

前端 未结 7 1513
陌清茗
陌清茗 2020-12-16 09:15

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_VIOLAT

相关标签:
7条回答
  • 2020-12-16 09:38

    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>
    
    0 讨论(0)
  • 2020-12-16 09:40

    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.

    0 讨论(0)
  • 2020-12-16 09:43

    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

    0 讨论(0)
  • 2020-12-16 09:48

    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

    0 讨论(0)
  • 2020-12-16 09:52

    My app was missing NSFaceIDUsageDescription key

    0 讨论(0)
  • 2020-12-16 09:57

    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.

    0 讨论(0)
提交回复
热议问题