ios将事件添加到谷歌日历

时间:2013-07-20 13:12:33

标签: iphone ios google-calendar-api

我已经搜索了如何添加事件t用户谷歌日历。在我的项目中,我有数据库,包含事件(title,startDate,endDate等)。当用户点击同步按钮时,所有这些事件都应该添加到用户谷歌日历中。

我从here下载了api。但它适用于MAC OS。由于我从未参与过MAC OS应用程序,因此无法理解如何在IOS应用程序中使用它。

请帮助我并告诉使用哪个视图控制器询问用户名和密码,然后登录谷歌日历服务并在其中添加活动。

谢谢。

我得到了http://code.google.com/p/google-api-objectivec-client/。但它很难理解。它从首选项中获取用户名和密码。然后获取日历并添加事件,但要添加我们需要票证和更多的东西。这段代码做了一些事情。

在他们的添加事件方法中,我编写了自己的事件对象,并尝试添加它,但它不起作用。这是代码:

- (void)insertCalendarEvent:(GDataEntryCalendarEvent *)event toCalendar:(GDataEntryCalendar *)calendar
{
    NSLog(@"adding event");

    GDataDateTime *time = [GDataDateTime dateTimeWithDate:[NSDate date] timeZone:(NSTimeZone*)[NSTimeZone timeZoneForSecondsFromGMT:0]];

    GDataEntryCalendarEvent *newEntry = [GDataEntryCalendarEvent calendarEvent];
    [newEntry setTitleWithString:@"title"];
    [newEntry addLocation:[GDataWhere whereWithString:@"pune"]];
    [newEntry addTime:[GDataWhen whenWithStartTime:time endTime:time]];

  [googleCalendarService fetchEntryByInsertingEntry:newEntry
                                         forFeedURL:[[calendar alternateLink] URL]
                                           delegate:self
                                  didFinishSelector:@selector( insertTicket:finishedWithEntry:error: )];

}

我的要求很简单。我只想将自定义事件添加到Google日历中。获取日历,获取票证,并在for循环中添加我的所有活动。

3 个答案:

答案 0 :(得分:4)

除了使用Google API和用户需要再次登录的新窗口外,您应该使用EventKit,这非常简单,您可以同步到用户想要的日历,而不仅仅是Google卡。

答案 1 :(得分:1)

正如@Tuss Laszlo所提到的,Google API客户端库是将事件仅添加到Google日历的最佳选择。 Google的示例代码中包含日历示例。有关添加日历事件的完整实施,请参阅the example

答案 2 :(得分:1)

我有与您相同的要求来整合Google日历和同步事件。我研究并找到了来自here的文档,但我没有清楚地理解它,所以后来我发现了另一个用于访问Google日历API的好tutorial。您可以根据自己的要求进行尝试。

相关问题