Fer*_*ics 11 nsurl nsdate eventkit swift
我想知道是否有人知道如何使用APP的特定事件启动日历
我做了一些研究,我想出了两种方法,使用NSURL从应用程序内部打开本机日历
"calshow://" 在当前日期打开日历"calshow:\(someNSDate.timeIntervalSinceReferenceDate)" 打开日期为的日历 someNSDate我还发现这个网站列出calshow:x?eventid=id的网址,但我不知道,如果这个工程(列为不公开),我无法得到它的工作我自己使用,尝试:
event.calendarItemExternalIdentifier
event.eventIdentifier
event.calendarItemIdentifier
Run Code Online (Sandbox Code Playgroud)
目前我正在使用此代码在finalInterval日期,事件日期打开日历应用程序
if let day = hackathon?.start {
let today = NSDate()
let timeSince = NSDate.timeIntervalSinceReferenceDate() // this plus
let todayToFutureDate = day.timeIntervalSinceDate(today)
let finalInterval = todayToFutureDate + timeSince
UIApplication.sharedApplication().openURL(NSURL(string: "calshow:\(finalInterval)")!)
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是打开日历,其中包含事件ID或类似事件的日历
如果您对更多信息有任何疑问,请问,我会在附近
试试这个,创建这个功能
func gotoAppleCalendar(date: NSDate) {
let interval = date.timeIntervalSinceReferenceDate
let url = NSURL(string: "calshow:\(interval)")!
UIApplication.sharedApplication().openURL(url)
}
Run Code Online (Sandbox Code Playgroud)
使用事件开始日期作为参数调用该函数
gotoAppleCalendar(event.startDate)
Run Code Online (Sandbox Code Playgroud)
这打开了显示添加事件的苹果日历
| 归档时间: |
|
| 查看次数: |
4369 次 |
| 最近记录: |