ios - Deleting event from iCal not working when iCal is not in background -


am trying delete event ical notification. event getting deleted if ical in background. if same notification sent after closing ical, event not deleted. trying access ical using method in mycalendar.m

+ (void)requestaccess:(void (^)(bool granted, nserror *error))callback {   if (eventstore == nil) {     eventstore = [[ekeventstore alloc] init];   }   [eventstore requestaccesstoentitytype:ekentitytypeevent completion:callback]; } 

and trying delete event using following method in appdelegate.m

[mycalendar requestaccess:^(bool granted, nserror *error) {             if (granted) {                 if ([[self.launchoptions objectforkey:@"type"] isequaltostring:@"remainder"] || [[self.launchoptions objectforkey:@"type"] isequaltostring:@"cancelappointment"]) {                     if ([[self.launchoptions objectforkey:@"type"]                          isequaltostring:@"cancelappointment"]) {                         if (![mycalendar removeeventwitheventidentifier:                               [self.launchoptions objectforkey:@"eventid"]]) {                         }                     }                 }             }        }]; 

am deleting event ical using following method in mycalendar.m

+ (bool)removeeventwitheventidentifier:(nsstring *)identifier {   ekevent *event2 = [eventstore eventwithidentifier:identifier];   bool result = no;   if (event2 != nil) {     nserror *error = nil;     result = [eventstore removeevent:event2 span:ekspanthisevent error:&error];   }   return result; } 

thanks in advance!

you have initialize event store object before using.

    + (bool)removeeventwitheventidentifier:(nsstring *)identifier {         ekeventstore* eventstore = [[ekeventstore alloc] init];         ekevent *event2 = [eventstore eventwithidentifier:identifier];         bool result = no;         if (event2 != nil) {         nserror *error = nil;         result = [eventstore removeevent:event2 span:ekspanthisevent        error:&error];         }       return result;       } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -