本文介绍了如何使用Google Calendar API iOS Swift创建事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想开发一个演示应用程序,它将使用我的应用程序创建事件,使用Google Calendar API存储它,然后获取所有数据并给出提醒.我已引用此链接来获取数据并进行设置,但我没有获得如何创建事件的信息.谁能指导我该怎么做?我搜索了很多关于使用iOS创建事件的信息,但是对于Google Calendar API却没有任何有用的信息,我使用EventKit框架找到了所有东西.

I want to develop one demo app which will create events using my Application, store it using Google Calendar API and then fetch all the data and gives reminder. I have referred this link to fetch data and for setup, but I am not getting how to create events. Can anyone guide me how can I do this? I searched a lot for creating events using iOS, but I don't get anything useful for Google Calendar API, I found all the stuff using EventKit framework.

请帮助我.谢谢.

推荐答案

我找到了一个教程: "iOS SDK:使用Google日历" ,在本教程中,他们提供了有关下载日历和创建新日历的见解.带有说明和日期/时间的事件.

I've found a tutorial: "iOS SDK: Working with Google Calendars", in this tutorial they provide insights on downloading the calendars, and creating a new event with a description and a date/time.

  • 事件描述
  • 活动日期/时间
  • 目标日历
  • An event description
  • An event date/time
  • A target calendar

添加事件(目标C)的代码示例:

A code example for adding event(Objective C):

// Create the URL string of API needed to quick-add the event into the Google calendar.
// Note that we specify the id of the selected calendar.
NSString *apiURLString = [NSString stringWithFormat:@"https://www.googleapis.com/calendar/v3/calendars/%@/events/quickAdd",
                          [_dictCurrentCalendar objectForKey:@"id"]];

// Build the event text string, composed by the event description and the date (and time) that should happen.
// Break the selected date into its components.
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents = [[NSCalendar currentCalendar] components:NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit|NSHourCalendarUnit|NSMinuteCalendarUnit
                                                 fromDate:_dtEvent];

if (_isFullDayEvent) {
    // If a full-day event was selected (meaning without specific time), then add at the end of the string just the date.
    _strEventTextToPost = [NSString stringWithFormat:@"%@ %d/%d/%d", _strEvent, [dateComponents month], [dateComponents day], [dateComponents year]];
}
else{
    // Otherwise, append both the date and the time that the event should happen.
    _strEventTextToPost = [NSString stringWithFormat:@"%@ %d/%d/%d at %d.%d", _strEvent, [dateComponents month], [dateComponents day], [dateComponents year], [dateComponents hour], [dateComponents minute]];
}

// Show the activity indicator view.
[self showOrHideActivityIndicatorView];

// Call the API and post the event on the selected Google calendar.
// Visit https://developers.google.com/google-apps/calendar/v3/reference/events/quickAdd for more information about the quick-add event API call.
[_googleOAuth callAPI:apiURLString
       withHttpMethod:httpMethod_POST
   postParameterNames:[NSArray arrayWithObjects:@"calendarId", @"text", nil]
  postParameterValues:[NSArray arrayWithObjects:[_dictCurrentCalendar objectForKey:@"id"], _strEventTextToPost, nil]];

我认为您可以从 iOS快速入门Google .

我希望这会有所帮助.祝你好运:)

I hope this helps. Goodluck :)

这篇关于如何使用Google Calendar API iOS Swift创建事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:17