How to use google calendar list insert with Objective-C.
https://developers.google.com/google-apps/calendar/v3/reference/calendarList/insert#response
I want add a public calendar[ID:[email protected]] to my calendar but there is some error
Error Domain=com.google.GTLJSONRPCErrorDomain Code=**403** "(Insufficient Permission)" UserInfo={error=Insufficient Permission, NSLocalizedFailureReason=(Insufficient Permission), GTLStructuredError=GTLErrorObject 0x7f9b40d0da00: {message:"Insufficient Permission" data:[1] code:403}}
2016-03-10 17:34:23.022 calendar20160225[10337:413037] error:(null)
I edit from https://developers.google.com/google-apps/calendar/quickstart/ios
I add this and got the error
-(void)myCalendarQuery
{
NSString* enter code herenewCalendarName=@"[email protected]";
GTLCalendarCalendarListEntry *entry=[GTLCalendarCalendar object];
GTLServiceCalendar *service = self.service;
GTLCalendarCalendar *newEntry = [GTLCalendarCalendar object];
newEntry.summary = newCalendarName;
newEntry.timeZone = [[NSTimeZone localTimeZone] name];
GTLQueryCalendar *query = [GTLQueryCalendar queryForCalendarsInsertWithObject:newEntry];
GTLServiceTicket* editCalendarListTicket =[[GTLServiceTicket alloc]init];
[self.service executeQuery:query
delegate:self
didFinishSelector:@selector(displayResultWithTicket:finishedWithObject:error:)];
editCalendarListTicket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {
// Callback
//editCalendarListTicket = nil;
if (error == nil) {
[self fetchCalendarList];
} else {
NSLog(@"error:%@",error);
[self fetchCalendarList];
[self showAlert:@"Add failed" message:[NSString stringWithFormat:@"Calendar add failed: %@", error]];
}
}];
//[email protected]
GTLQueryCalendar *query2 = [GTLQueryCalendar queryForEventsListWithCalendarId:@"[email protected]"];
[GTLQueryCalendar queryForEventsInsertWithObject:query calendarId:@"[email protected]"];
query.maxResults = 10;
query.timeMin = [GTLDateTime dateTimeWithDate:[NSDate date]
timeZone:[NSTimeZone localTimeZone]];;
query.singleEvents = YES;
query.orderBy = kGTLCalendarOrderByStartTime;
[self.service executeQuery:query
delegate:self
didFinishSelector:@selector(displayResultWithTicket:finishedWithObject:error:)];
// [GTLQueryCalendar queryForAclInsertWithObject:query calendarId:@"[email protected]"];
}