3

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.

Please help me. Thank You.

4
  • No.. I am able to fetch data using this link. but I want to create events from my app. I don't know how to do that Commented May 4, 2016 at 7:49
  • Actually, until you can't tell where you were going wrong nobody can help. It's google developer form what you following and mostly there is no sign of issues in their forms. so cross check your steps with the available steps on the google form that you provided as a link! Commented May 4, 2016 at 7:54
  • I have no issues with that code. That code is used for fetching events from google Calendar API and it works perfectly. I am asking that I want to create and register events using my iOS Application. Commented May 4, 2016 at 8:01
  • i need to fetch events from google calendar, can u help me to do Commented Jun 15, 2022 at 11:06

2 Answers 2

1

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.

Regarding our app structure, the basic view is going to be a table view that will contain three sections for setting the following data:

  • An event description
  • An event date/time
  • A target calendar

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]];

I think you can implement this from what you have started in the iOS Quickstart Google.

I hope this helps. Goodluck :)

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for your help, but actually I saw this link and it is in objective C. I don't know how to convert Objective C code to swift. Can you help me in this?@Mr. Rebot
@Mr.Rebot i have some doubt. actually i am also working on google calendar events. my doubt is acutally i gave client id hard code. but i need to pass client id dynamically. so how to pass client id dynamically. for example user has to login google in my application. then i need to display his related events. another user login same mobile. then i need to display his related events. so we need to generate client id dynamically. how to do this thing?? will you guide me plz
i implemented sample code of google calendar it is working fine but how will i proceed further to create event in google calendar through my app
0

first you have to create a public API and get is key. and set its url using the following code

let url = NSURL(string: "https://www.googleapis.com/calendar/v3/calendars/email.gmail.com/events?maxResults=15&key=APIKey-here")

It works for you

1 Comment

Is there any tutorial available which I can refer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.