我有一个应用程序,我必须在其中添加默认日历中的事件,该日历在 iOS 10 之前运行良好。现在在 iOS 10 中它不授予访问权限。我已将 use legacy swift language version
设置为 yes
。我的代码是
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")
}
虽然调试我的应用程序在 Xcode 8 中的 eventStore.requestAccessToEntityType
处崩溃。
我的应用已上线,我需要解决它。任何帮助都是适当的。提前致谢。
最佳答案
在iOS 10 build上,需要在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.
来自 Apple Docs
关于ios - iOS 10 及更高版本中的 EKEventStore requestAccessToEntityType 崩溃应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39918076/