Add event to google calendar from ios -


i have followed following tutorial fetch events google calendar working fine. https://developers.google.com/google-apps/calendar/quickstart/ios

now stuck in insert event ios app can synced web well. please guide me in right direction or post sample code.

i using code authorization in viewdidload

// initialize google calendar api service & load existing credentials keychain if available. self.service = [[gtlservicecalendar alloc] init]; self.service.authorizer = [gtmoauth2viewcontrollertouch authforgooglefromkeychainforname:kkeychainitemname                                                       clientid:kclientid                                                   clientsecret:kclientsecret]; 

authorization seems fine because fetch events working fine. using following code add event

- (void)addanevent {     // make new event, , show user edit     gtlcalendarevent *newevent = [gtlcalendarevent object];     newevent.summary = @"sample added event";     newevent.descriptionproperty = @"description of sample added event";      // we'll set start time now, , end time hour now,     // reminder 10 minutes before     nsdate *anhourfromnow = [nsdate datewithtimeintervalsincenow:60*60];     gtldatetime *startdatetime = [gtldatetime datetimewithdate:[nsdate date]                                                   timezone:[nstimezone systemtimezone]];     gtldatetime *enddatetime = [gtldatetime datetimewithdate:anhourfromnow                                                 timezone:[nstimezone systemtimezone]];      newevent.start = [gtlcalendareventdatetime object];     newevent.start.datetime = startdatetime;      newevent.end = [gtlcalendareventdatetime object];     newevent.end.datetime = enddatetime;      gtlcalendareventreminder *reminder = [gtlcalendareventreminder object];     reminder.minutes = [nsnumber numberwithinteger:10];     reminder.method = @"email";      newevent.reminders = [gtlcalendareventreminders object];     newevent.reminders.overrides = [nsarray arraywithobject:reminder];     newevent.reminders.usedefault = [nsnumber numberwithbool:no];      [self addevent:newevent]; }   - (void)addevent:(gtlcalendarevent *)event {     gtlquerycalendar *query = [gtlquerycalendar queryforeventsinsertwithobject:event                                                                 calendarid:@"primary"];     [self.service executequery:query                   delegate:self          didfinishselector:@selector(displayaddeventresultwithticket:finishedwithobject:error:)]; }  - (void)displayaddeventresultwithticket:(gtlserviceticket *)ticket                  finishedwithobject:(gtlcalendarevents *)events                               error:(nserror *)error {     if (error == nil) {         nslog(@"i think event has been added successfully!");      } else {         nslog(@"error : %@", error.localizeddescription);     } } 

but getting error in response "the operation couldn’t completed. (insufficient permission)"

thanks,

to add event calendar use following method

[gtlquerycalendar queryforeventsinsertwithobject:youreventobject calendarid:yourcalendarid] 

also note, have authorize scope kgtlauthscopecalendar have read/write access.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -