Always get CNErrorDomain code=100

Everytime I request the access in the CNContactStore on my real iPhone 6 like:

let cnStore = CNContactStore()
cnStore.requestAccessForEntityType(CNEntityType.Contacts) { hasPermission, error in
     if error != nil {
          print(error)
     }
}


I get the following error:

Error Domain=CNErrorDomain Code=100 "Access Denied" UserInfo={NSLocalizedDescription=Access Denied, NSLocalizedFailureReason=This application has not been granted permission to access Contacts.}

Add a Comment

Replies

Have you checked CNContactStore.authorizationStatusForEntityType(.Contacts) == .NotDetermined before calling requestAccessForEntityType(_:) ?

Yes, I did it like:

switch CNContactStore.authorizationStatusForEntityType(CNEntityType.Contacts) {
case .Authorized:
     print("has Permission")
case .Denied, .Restricted:
     print("has no Permission")
case .NotDetermined:
     let cnStore = CNContactStore()
     cnStore.requestAccessForEntityType(CNEntityType.Contacts) { hasPermission, error in
          if error != nil {
               print(error!)
          }
     }
}

Sorry, then I cannot reproduce the issue with my iPod touch 6G running iOS 9 beta 4.

The value of error is always nil with my tapping OK for the alert "MyContacts" Would Like to Access Your Contacts.

Where do you put your requestAccessForEntityType code?

When I press a button.

But on my iPad mini everything works fine.

No difference on iOS 9 Beta 5. I dont get asked if my app getan the permission zu access contacts.