I want to insert event in google calendar without using any third parties. Please help me if any one know it. Thanks in advance.
-
You to have the power of Google: https://developers.google.com/google-apps/calendar/v3/reference/events/insert – Linda Lawton - DaImTo Oct 03 '16 at 10:41
3 Answers
You want add some event in google calendar, well you can do this using by following google api library:I posted event to google calendar using below library.
https://github.com/google/google-api-objectivec-client-for-rest
They give brief description for adding event to google calendar with code. #pragma mark Add, Edit, and Delete an Event
- (void)addAnEvent {
// Make a new event, and show it to the user to edit
GTLRCalendar_Event *newEvent = [GTLRCalendar_Event object];
newEvent.summary = @"Sample Added Event";
newEvent.descriptionProperty = @"Description of sample added event";
// We'll set the start time to now, and the end time to an hour from
now,
// with a reminder 10 minutes before
NSDate *anHourFromNow = [NSDate dateWithTimeIntervalSinceNow:(60 * 60)];
// Include an offset minutes that tells Google Calendar that these
dates
// are for the local time zone.
NSInteger offsetMinutes = [NSTimeZone localTimeZone].secondsFromGMT / 60;
GTLRDateTime *startDateTime = [GTLRDateTime dateTimeWithDate:[NSDate date]offsetMinutes:offsetMinutes];
GTLRDateTime *endDateTime = [GTLRDateTime dateTimeWithDate:anHourFromNow
offsetMinutes:offsetMinutes];
newEvent.start = [GTLRCalendar_EventDateTime object];
newEvent.start.dateTime = startDateTime;
newEvent.end = [GTLRCalendar_EventDateTime object];
newEvent.end.dateTime = endDateTime;
GTLRCalendar_EventReminder *reminder = [GTLRCalendar_EventReminder
object];
reminder.minutes = @10;
reminder.method = @"email";
newEvent.reminders = [GTLRCalendar_Event_Reminders object];
newEvent.reminders.overrides = @[ reminder ];
newEvent.reminders.useDefault = @NO;
[self addEvent:event];}
- (void)addEvent:(GTLRCalendar_Event *)event {
GTLRCalendarService *service = self.calendarService;
GTLRCalendar_CalendarListEntry *selectedCalendar = [self
selectedCalendarListEntry];
NSString *calendarID = selectedCalendar.identifier;
GTLRCalendarQuery_EventsInsert *query =
[GTLRCalendarQuery_EventsInsert queryWithObject:event
calendarId:calendarID];
self.editEventTicket = [service executeQuery:query
completionHandler:^(GTLRServiceTicket
*callbackTicket,
GTLRCalendar_Event *event,
NSError *callbackError) {
// Callback
self.editEventTicket = nil;
if (callbackError == nil) {
[self displayAlert:@"Event Added"
format:@"Added event \"%@\"",
event.summary];
[self fetchSelectedCalendar];
} else {
[self displayAlert:@"Add failed"
format:@"Event add failed: %@", callbackError];
} }];
}
- (void)editSelectedEvent {
// Show the selected event to the user to edit
GTLRCalendar_Event *eventToEdit = [self selectedEvent];
if (eventToEdit) {
EditEventWindowController *controller = [[EditEventWindowController
alloc] init];
[controller runModalForWindow:self.window
event:eventToEdit
completionHandler:^(NSInteger returnCode,
GTLRCalendar_Event *event) {
// Callback
if (returnCode == NSModalResponseOK) {
[self editSelectedEventWithEvent:event];
}
}];
}
}

- 115
- 1
- 9
-
hiii could u help me how to integrate google calendar in swift @Dipak Dhondge – Dilip Tiwari Dec 08 '17 at 05:59
-
-
-
I have code in Objective C only.Recently I have integrated with My project.Sorry dude I don't have code for swift.But I am going to share some useful url for calendar.Please have a look 1.https://stackoverflow.com/questions/47801031/adding-a-google-calendar-event-in-swift 2.https://github.com/theandrewdavis/ios-google-calendar 3.I referred google library for adding, creating & deleting events :-https://github.com/google/google-api-objectivec-client-for-rest – Dipak Dhondge Feb 26 '18 at 10:23
-
-
Hello Dilip, I followed the steps given in the following URL:- https://developers.google.com/google-apps/calendar/quickstart/ios Follow above URL steps. – Dipak Dhondge Feb 27 '18 at 04:56
Do you want to post or insert some event in google calendar, well you can do this using following :
Use https POST request, and make a NSURLSession request, using url
https://www.googleapis.com/calendar/v3/calendars/calendarId/events
after events, add your data.

- 347
- 3
- 17
If you want to insert an event in a specific time, then your request should look like this.
POST https://www.googleapis.com/calendar/v3/calendars/primary/events?key={YOUR_API_KEY}
{
"end": {
"dateTime": "2016-10-08T8:00:00",
"timeZone": "Asia/Manila"
},
"start": {
"dateTime": "2016-10-08T6:00:00",
"timeZone": "Asia/Manila"
}
}
You need to specify the start.dateTime
and the end.dateTime
in your request.
Include also the timeZone
that you want to use. This API needs an IANA Time Zone Format that you can see in this link.

- 7,576
- 2
- 16
- 31
-
can we convert general timezone format (eg.`IST`) to IANA format(eg.`Asia/Kolkatta`) – Varshini Jul 25 '17 at 06:56
-
The Asia/Kolkatta is available in the IANA format, can you clarify your question? – KENdi Jul 25 '17 at 09:26
-
I've a timezone which returns the timezone string as `IST`, is it possible to convert `IST` to IANA format like `Asia/Kolkatta`? – Varshini Jul 25 '17 at 10:06
-
But calendar API only accepts an IANA format. Try to check this [SO question](https://stackoverflow.com/questions/18014341/how-to-convert-time-correctly-across-timezones) if it can help you. – KENdi Jul 25 '17 at 10:08
-
hiii could u help me how to integrate google calendar in swift @KENdi – Dilip Tiwari Dec 08 '17 at 05:59