ios - Modifying EKParticipants (attendees) in EventKit like Sunrise -
my goal add invitees ekevent. i've looked other questions this, such this one, impossible add ekparticipants ekevent programmatically. see attendees property read-only, see other services sunrise using in mobile app.
i'm confident they're using system @ least partially integrates eventkit because they're pulling in calendars user's ical app. invites sent added exchange account, example, sent exchange service opposed sunrise's own invite (a result of either posting event straight exchange or posting ical).
any workaround restriction helpful - maybe endpoint on exchange can called add/remove invitees? workaround inside of eventkit? long it's not private apple api, i'd more happy try out.
thanks!
i figured out!
essentially, 1 must go ekattendee class, inherits ekparticipant. did creating generic instance of class using nsclassfromstring() method.
once have attendee, can set properties using setvalue:forkey: function.
lastly, compile ekattendee instances array, , set ekevent's attendees property.
i tested exchange account on device, , worked charm - invite sent , everything!
the code below i'm using set attendees of events. example creating new events, can done existing events making copy of attendees list on ekevent, modifying , re-setting it.
//create generic event info ekevent *event = [ekevent eventwitheventstore:database]; event.title = @"test event"; event.location = @"test location"; event.notes = @"example notes"; event.startdate = [nsdate date]; event.enddate = [[nsdate date] datebyaddingtimeinterval:(60 * 60)]; event.calendar = exchange; //do our super clever hack nsmutablearray *attendees = [nsmutablearray new]; (int = 0; < 5; i++) { //initialize ekattendee object, not accessible , inherits ekparticipant class classname = nsclassfromstring(@"ekattendee"); id attendee = [classname new]; //set properties of attendee using setvalue:forkey: [attendee setvalue:@"invitee" forkey:@"firstname"]; [attendee setvalue:[nsstring stringwithformat:@"#%i", + 1] forkey:@"lastname"]; [attendee setvalue:@"test@email.com" forkey:@"emailaddress"]; //add attendee list can assign event [attendees addobject:attendee]; } //finally, add invitees event [event setvalue:attendees forkey:@"attendees"]; //save event! nserror *error = nil; [database saveevent:event span:ekspanthisevent error:&error]; if (error) { nslog(@"save failed error: %@", error); } else { nslog(@"success!"); }
Comments
Post a Comment