ios - 通过API在Google日历上创建重复事件

标签 ios swift api google-calendar-api recurrence

我无法使用Google Calendar API创建重复发生的事件。我可以创建单个事件,但是如果我在recurrence属性中添加“recurrence”规则,则会收到一条错误消息,提示“操作无法完成。(无效值)”(timezone.name = America /纽约)

我正在使用以下代码创建事件对象,如果条件为false,则在Google日历上创建事件
我的问题是,如何使用Google Calendar API创建重复 Activity ?谁能告诉我我在下面做错了什么?

先谢谢您的帮助。

let gEvent = GTLCalendarEvent()
    let timeZone = NSTimeZone.systemTimeZone()

    let startTime = NSDate.dateFromString("2016-10-18 21:31:00 +0000")
    let endTime = NSDate.dateFromString("2016-10-18 22:31:00 +0000")

    let start = GTLCalendarEventDateTime()
    let end = GTLCalendarEventDateTime()

    if event.EventRepeat.toBool() == true {
        end.dateTime = GTLDateTime(date:endTime, timeZone: nil)
        start.dateTime =  GTLDateTime(date:startTime, timeZone: nil)
        start.timeZone = timeZone.name
        end.timeZone = timeZone.name
        gEvent.recurrence = ["FREQ=WEEKLY;BYDAY=SU,MO,TU,WE,TH,FR,SA;INTERVAL=1;UNTIL=20171031T040000Z"]

    }else{
        end.dateTime = GTLDateTime(date:endTime, timeZone: timeZone)
        start.dateTime =  GTLDateTime(date:startTime, timeZone: timeZone)
    }

    gEvent.start = start
    gEvent.end = end
    gEvent.summary = "Example Event"
    gEvent.descriptionProperty = "Example Event Description"

    return gEvent

最佳答案

RRule设置错误。解决了!这是一个模板
RRULE:FREQ=WEEKLY;UNTIL=20190628;BYDAY=SU,MO

关于ios - 通过API在Google日历上创建重复事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40118538/

相关文章:

ios - 如何在整个应用程序中禁用 NSLog?

ios - 更新已保存的 Codable 结构以添加新属性

swift - 当 nil 应该返回一个特定的默认值时,swift 在函数参数中使用可选的最干净的方法是什么?

python - 将 XML 解析为 Pandas DataFrame 为 CSV

javascript - 不能在 fetch api 中使用变量

ios - 如何以编程方式删除 UITextField 的内容?

ios - 无法打开,因为在ios中无法解析项目文件

c# - 在类库中设置配置设置的最标准方法

ios - 生成无限数量的节点并通过点击它们来销毁

ios - 如何在tableViewCell中获取准确的星星