gpt4 book ai didi

ios - iOS 10 及更高版本中的 EKEventStore requestAccessToEntityType 崩溃应用程序

转载 作者:搜寻专家 更新时间:2023-10-31 21:59:37 48 4
gpt4 key购买 nike

我有一个应用程序,我必须在其中添加默认日历中的事件,该日历在 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 处崩溃。

Screenshot of debug

我的应用已上线,我需要解决它。任何帮助都是适当的。提前致谢。

最佳答案

在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/

48 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com