简体   繁体   English

ios将事件添加到谷歌日历

[英]ios Add Event to google calendar

I have searching how to add event t users google calendar. 我已经搜索了如何添加事件t用户谷歌日历。 In my project I have database with events(title,startDate,endDate etc). 在我的项目中,我有数据库,包含事件(title,startDate,endDate等)。 When user clicks sync button all this events should be add to users google calendar. 当用户点击同步按钮时,所有这些事件都应该添加到用户谷歌日历中。

I downloaded api from here . 我从这里下载了api。 But its for MAC OS. 但它适用于MAC OS。 Since I never worked on MAC OS application I cant understand how to use it in IOS app. 由于我从未参与过MAC OS应用程序,因此无法理解如何在IOS应用程序中使用它。

Please help me and tell which view controller to use asking for username and password, then login to google calendar service and add event in it. 请帮助我并告诉使用哪个视图控制器询问用户名和密码,然后登录谷歌日历服务并在其中添加事件。

Thank you. 谢谢。

I got http://code.google.com/p/google-api-objectivec-client/ . 我得到了http://code.google.com/p/google-api-objectivec-client/ But its difficult to understand. 但它很难理解。 It takes username and password from preferences. 它从首选项中获取用户名和密码。 Then gets calendars and adds events, but to add we need ticket and some more things. 然后获取日历并添加事件,但要添加我们需要票证和更多的东西。 This code did some things. 这段代码做了一些事情。

In their add event method I wrote my own event object and tried to add that, but its not working. 在他们的添加事件方法中,我编写了自己的事件对象,并尝试添加它,但它不起作用。 Here is the code: 这是代码:

- (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: )];

}

My requirement is simple. 我的要求很简单。 I just want add my custom events to google calendar. 我只想将自定义事件添加到Google日历中。 Get calendar, get ticket, and in for loop add all my events. 获取日历,获取票证,并在for循环中添加我的所有活动。

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

As @Tuss Laszlo mentioned, the Google API Client library is your best option to add events only to a Google Calendar. 正如@Tuss Laszlo所提到的,Google API客户端库是将事件仅添加到Google日历的最佳选择。 Google has a calendar sample in their example code. Google的示例代码中包含日历示例。 See the example for the full implementation of adding calendar events. 有关添加日历事件的完整实现,请参阅示例

I have the same requirement like yours to integrate google calendar and syncing events. 我有与您相同的要求,以整合谷歌日历和同步事件。 I researched and found documentation from here but I didn't understand it clearly, so later I found another good tutorial for accessing google calendar API's. 我从这里研究并找到了文档,但我没有清楚地理解它,所以后来我发现了另一个访问谷歌日历API的好教程 You can try this for your requirement. 您可以根据您的要求尝试此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM