7

I worked through the iOS Quickstart Guide provided by google to notice, that it is outdated for a very long time already.

So I researched the whole day to find out how it is supposed to work now but I did not find a working solution / description on how to do it.

I have an iOS App with a calendar. The user can decide which calendar should be used to synchronise calendar events between app and calendar. Google Calendar and Apple Calendar should be supported. The Apple Calendar synchronisation is working perfectly. For the Google Calendar I could not find any solution yet. It should be possible for users of an google calendar to synchronize all events with our iOS app (including adding, removing and changing events).

Is there any source for that which is not outdated and which is describing on how to do it?

1 Answer 1

1

Google has an example app on Github here: https://github.com/google/google-api-objectivec-client-for-rest

If you dig through the app, there's an Objective-C example of creating an event, it should give you a good place to start for Swift as well:

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

Additionally, you can also use the EventKit and let the user sync their calendar as they see fit, as described here: ios Add Event to google calendar

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

2 Comments

could u provide code for adding event to google calendar in swift @Adis
could u tell me

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.