Reputation: 61840
This is what I have so far:
private let contactStore = CNContactStore()
private func requestAccessForContacts() {
switch CNContactStore.authorizationStatusForEntityType(.Contacts) {
case .Denied, .NotDetermined:
contactStore.requestAccessForEntityType(.Contacts, completionHandler: { access, error in
if access {
print("super")
} else {
print("problem")
}
})
case .Authorized:
print("ok")
case .Restricted:
print("restricted")
}
}
The problem
is printed on console, but nothing is displayed on screen, no request for access. Why?
Upvotes: 1
Views: 407
Reputation: 16302
Your code works; I was able to replicate the problem by first rejecting access to contact and re-running the app.
Once you have disallowed access, subsequent running of the app would log "problem" without displaying any request window.
If one wanted to see this request window again after denying, one could, however, go to "Settings" -> "Reset" and click "Reset Location And Privacy" in the simulator.
After having done so, the next time you run the app, a request window would pop up again.
Upvotes: 3