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
}
}
}
}
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".