【问题标题】:iOS - Can't add calendar event to Gmail calendar with EventKitiOS - 无法使用 EventKit 将日历事件添加到 Gmail 日历
【发布时间】:2013-11-22 18:36:04
【问题描述】:

我想将新的日历事件添加到默认 iOS 日历。在用户使用 Gmail 同步日历之前,这一切正常。

我使用以下代码:

    if (!calendar) {

    calendar = [EKCalendar calendarForEntityType:EKEntityTypeEvent eventStore:eventStore];

    // set calendar name
    [calendar setTitle:@"My calendar"];

    EKSource *theSource = [eventStore defaultCalendarForNewEvents].source;
    calendar.source = theSource;

    // save this in NSUserDefaults data for retrieval later
    NSString *calendarIdentifier = [calendar calendarIdentifier];

    NSError *error = nil;
    BOOL saved = [eventStore saveCalendar:calendar commit:YES error:&error];
    if (saved) {
        // saved successfuly, store it's identifier in NSUserDefaults
        [[NSUserDefaults standardUserDefaults] setObject:calendarIdentifier forKey:@"railplanner_calendar_identifier"];
    } else {
        // unable to save calendar
        return NO;
    }
}

当启用 iCloud 或使用本地日历时,这可以正常工作。 但是当用户使用 Gmail 同步日历时,我的自定义日历不会出现在日历列表中。本地日历也消失了。

有谁知道如何将带有新事件的新日历添加到 Gmail(或 Google)日历?

非常感谢。

【问题讨论】:

    标签: ios gmail google-calendar-api eventkit


    【解决方案1】:

    这对于当前的谷歌日历同步可能是不可能的,你可以检测默认日历的类型,如果谷歌使用相关的谷歌 iPhone API 来创建你的新日历(我知道这不是很有帮助)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-29
      • 1970-01-01
      相关资源
      最近更新 更多