My code crashes as soon as it tries to request access to the CNContactStore
. Any ideas if this is a beta issue?
var addressBookStore = CNContactStore()
addressBookStore.requestAccess(for: .contacts) { (granted, error)
in
// This console message is triggered at the crash - Messenger[836:1175155] [access] private
the crash occurs at this line and even preventing even printing the error!
Thanks in advance
As suggested here : https://developer.apple.com/reference/contacts
Important
An iOS app linked on or after iOS 10.0 must include in its Info.plist file the usage description keys for the types of data it needs to access or it will crash. To access Contacts data specifically, it must include NSContactsUsageDescription.
You have to addd NSContactsUsageDescription key in your Info.plist file
Then you will get authorization dialog. Without this key app will crash.
let addressBookStore = CNContactStore()
addressBookStore.requestAccess(for: CNEntityType.contacts) { (isGranted, error) in
print(isGranted)
print(error)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With