如何在 iOS 中以编程方式检查日历订阅的 ics 提要
How to check calendar subscribed ics feed programmatically in iOS
当您尝试订阅已订阅的 ics 提要时,它会显示:
我尝试使用此代码订阅:
UIApplication.sharedApplication().openURL(NSURL(string: "webcal://mlb.am/tix/yankees_schedule_full")!)
我想以编程方式检查是否已经订阅了 ics feed,这样我就可以阻止此警报。
提前致谢。
几乎花了 2 周的时间才找到解决方案。
func checkICS() {
let eventStrore = EKEventStore()
eventStrore.requestAccessToEntityType(EKEntityType.Event) { (granted, error) -> Void in
let allCalendars = eventStrore.calendarsForEntityType(EKEntityType.Event)
for currentCal : EKCalendar in allCalendars {
if (currentCal.type == EKCalendarType.Subscription && currentCal.title == "<Your ICS String>") {
print("Already Subscribed")
flag = true
}
}
if (flag == false) {
self.addICSSubscription()
}
}
}
当您尝试订阅已订阅的 ics 提要时,它会显示:
我尝试使用此代码订阅:
UIApplication.sharedApplication().openURL(NSURL(string: "webcal://mlb.am/tix/yankees_schedule_full")!)
我想以编程方式检查是否已经订阅了 ics feed,这样我就可以阻止此警报。 提前致谢。
几乎花了 2 周的时间才找到解决方案。
func checkICS() {
let eventStrore = EKEventStore()
eventStrore.requestAccessToEntityType(EKEntityType.Event) { (granted, error) -> Void in
let allCalendars = eventStrore.calendarsForEntityType(EKEntityType.Event)
for currentCal : EKCalendar in allCalendars {
if (currentCal.type == EKCalendarType.Subscription && currentCal.title == "<Your ICS String>") {
print("Already Subscribed")
flag = true
}
}
if (flag == false) {
self.addICSSubscription()
}
}
}