I have app in which I have to add events in default calendar which worked fine until iOS 10. Now in iOS 10 it is not granting access. I have set use legacy swift language version
to yes
. My code is
let eventStore = EKEventStore()
switch EKEventStore.authorizationStatusForEntityType(EKEntityType.Event) {
case .Authorized:
//access
case .Denied:
print("Access denied")
case .NotDetermined:
eventStore.requestAccessToEntityType(EKEntityType.Event, completion:
{[weak self] (granted: Bool, error: NSError?) -> Void in
if granted {
//access
} else {
print("Access denied")
}
})
default:
print("Case Default")
}
While debug my app is crashing at eventStore.requestAccessToEntityType
in Xcode 8.
My app is live and I need to solve it. Any help is appropriated. Thanks in advance.
On iOS 10 builds, you need to set a description message for the permission alert on Info.plist
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 Reminders and Calendar data specifically, it must include NSRemindersUsageDescription and NSCalendarsUsageDescription, respectively.
from Apple Docs
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