是否有可能迅速读取已订阅日历的服务器地址?
我的意思是这个领域: Server Field in Settings
我尝试过:
let eventStore = EKEventStore()
let url = URL(string: in_)
eventStore.requestAccess(to: .event, completion: {(granted, error) -> Void in
let allCalendars = eventStore.calendars(for: .event)
for currentCal : EKCalendar in allCalendars {
print(currentCal.title)
print(currentCal.type)
print(currentCal.source)
print(currentCal.calendarIdentifier)
if (currentCal.type == EKCalendarType.subscription && currentCal.title == url!.absoluteString) {
print("Already Subscribed")
alreadySubscribed = true
break
}
}
if (!alreadySubscribed) {
DispatchQueue.main.async(execute: {
if UIApplication.shared.canOpenURL(url!) {
UIApplication.shared.open(url!, options: [:], completionHandler: { (success) in
print("Open url : \(success)")
})
}
})
}
})
感谢您的帮助!