I'm updating my app to use CNContacts instead of AB. I've noticed that I am not getting prompted for granting permission to my Contacts. In the below switch, it is correctly telling me I am denied access - but then it doesn't prompt me to give it access. Furthermore, it just displays the picker and even stores the chosen properties into the tableview I am populating...
Is it not required to get permission to grab phone numbers or emails out of Contacts? I am confused why my code seems to be working if I am ".Denied"
//This code is called when you hit the "add a contact" button on my UI
switch CNContactStore.authorizationStatusForEntityType(.Contacts){
case .Authorized:
print("Already authorized")
presentPicker()
/* Access the address book */
case .Denied:
print("Denied access to address book")
store.requestAccessForEntityType(.Contacts){succeeded, err in
guard err == nil && succeeded else{
return
}
self.presentPicker()
}
case .NotDetermined:
store.requestAccessForEntityType(.Contacts){succeeded, err in
guard err == nil && succeeded else{
return
}
self.presentPicker()
}
default:
print("Not handled")
}
You do not need authorization to use CNContactsPickerViewController. It is "out of process"; it just works. In effect, it is the Contacts app sitting inside your app — and the user doesn't need permission to use the Contacts app.