Using the Google Calendar API in Swift

I worked through the iOS Quickstart Guide provided by Google to notice that it has been deprecated a very long time ago.

So, I researched all day to find out how it should work now, but I did not find a working solution / description on how to do this.

I have an iOS app with a calendar. The user can decide which calendar should be used to synchronize calendar events between the application and the calendar. Google Calendar and Apple Calendar must be supported. Apple Calendar sync works fine. For Google Calendar, I have not yet found a solution. Google Calendar users should be able to sync all events with our iOS app (including adding, deleting and changing events).

Is there a source for what is not outdated and describes how to do this?

+5
source share
1 answer

Google has a sample application on Github: https://github.com/google/google-api-objectivec-client-for-rest

If you dig an application, there is an Objective-C example of creating an event, it should also give you a good place for Swift:

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

In addition, you can also use EventKit and let the user synchronize their calendar as they wish, as described here: ios Add an event to Google Calendar

0
source

Source: https://habr.com/ru/post/1266862/


All Articles