0

I've seen one question like this one prior, but the answer was that permission was not needed because there was no editing... however the question as to why a user prompt was not being shown was not answered.
My issue is that I do need to edit so really do need this prompt so the user can give permission. Currently, I do not get prompted so access is always, "denied".

My snippets are below. (Xcode 7.2.1 iOS 9.2.1) Any help, tips would be appreciated. I do not see any others with this issue so don't know what the issue is... I tried the deprecated AB method as well with the same NO prompt for permissions... Is there some plist string that needs to be set like for location manager???
Thanks...

func checkContactsAccess() {
    switch CNContactStore.authorizationStatusForEntityType(.Contacts) {
        // Update our UI if the user has granted access to their Contacts
    case .Authorized:
        print("Access Granted")
        // Prompt the user for access to Contacts if there is no definitive answer
    case .NotDetermined :
        self.requestContactsAccess()

        // Display a message if the user has denied or restricted access to Contacts
    case .Denied,
    .Restricted:
        let alert = UIAlertController(title: "Privacy Warning!",
            message: "Permission was not granted for Contacts.",
            preferredStyle: .Alert)
        alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
        self.presentViewController(alert, animated: true, completion: nil)
    }
}

func requestContactsAccess() {

    contactStore.requestAccessForEntityType(.Contacts) {granted, error in
        if granted {
            dispatch_async(dispatch_get_main_queue()) {
                print("Access Granted")
                return
            }
        }
    }
}
ioski
  • 13
  • 3
  • To give more context, you can add your picker code, that would help, but I think I had enough info answer your immediate question. – benc Aug 05 '20 at 01:13

2 Answers2

0

The app using contact picker view does not need access to the user’s contacts and the user will not be prompted for “grant permission” access. The app has access only to the user’s final selection.

CNContactPickerViewController

benc
  • 1,381
  • 5
  • 31
  • 39
-1

Is there some plist string that needs to be set like for location manager

Yes, of course there is. And the name is completely parallel: "Privacy — Contacts Usage Description".

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • 1
    Thank you, Matt. I was thinking this was it but no joy.... I still do not get a prompt for permissions. I'm testing this in simulator and on an iPad... I've been resetting the location/privacy settings in-between tests (installing/uninstalling) etc... I get prompted for Location but not for Contacts which then always evaluates to denied. Any thoughts on this? – ioski Mar 18 '16 at 21:46
  • The question you asked was: "Is there some plist string that needs to be set like for location manager???" I answered that. – matt Mar 18 '16 at 23:13
  • "Pickers" come from the system, and only recently has Apple started adding more detail. (For example, somewhere in WWDC 2020, it was claimed that they are out-of-process, and also their displays cannot be captured by the app, but I haven't verified this). Pickers, by implication of not being stateful, do not use "purpose strings" in `Info.plist` (Sorry, but I did downvote the accepted answer) – benc Aug 05 '20 at 01:09