iOS 10 及更高版本中的 EKEventStore requestAccessToEntityType 应用程序崩溃
EKEventStore requestAccessToEntityType crashing app in iOS 10 and above
我有一个应用程序,我必须在其中添加默认日历中的事件,该日历在 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 中的 eventStore.requestAccessToEntityType
崩溃 8.
我的应用上线了,我需要解决它。任何帮助都是适当的。提前致谢。
let eventStore = EKEventStore()
switch EKEventStore.authorizationStatus(for: .event) {
case .authorized: break
//access
case .denied:
print("Access denied")
case .notDetermined:
eventStore.requestAccess(to: .event, completion:
{[weak self] (granted: Bool, error: Error?) -> Void in
if granted {
//access
} else {
print("Access denied")
}
})
default:
print("Case Default")
}
使用 XCode 8 和 swift 3,这是新格式。您是否在 iOS 10.
上测试了您的应用
在 iOS 10 个版本中,您需要为 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 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 中的 eventStore.requestAccessToEntityType
崩溃 8.
我的应用上线了,我需要解决它。任何帮助都是适当的。提前致谢。
let eventStore = EKEventStore()
switch EKEventStore.authorizationStatus(for: .event) {
case .authorized: break
//access
case .denied:
print("Access denied")
case .notDetermined:
eventStore.requestAccess(to: .event, completion:
{[weak self] (granted: Bool, error: Error?) -> Void in
if granted {
//access
} else {
print("Access denied")
}
})
default:
print("Case Default")
}
使用 XCode 8 和 swift 3,这是新格式。您是否在 iOS 10.
上测试了您的应用在 iOS 10 个版本中,您需要为 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