I'm attempting to determine which of an EKEvent's
attendees (EKPartipants
) is the current user. In iOS6, EKParticipant
exposes a property called isCurrentUser
http://developer.apple.com/library/ios/#documentation/EventKit/Reference/EKParticipantClassRef/Reference/Reference.html#//apple_ref/occ/cl/EKParticipant
which is supposed to provide precisely this information. Unfortunately, each time I lookup an EKParticipant's
isCurrentUser
property, it returns NO, even when that's clearly not the case.
Any help would be much appreciated!
Updated findings:
If you look up the event organizer, it correctly returns isCurrentUser == YES
if you're the organizer. But, if you retrieve yourself from the set of attendees, it returns isCurrentUser == NO
.
Example console output with the two different EKParticipant objects referring to the same person with the same email address:
(lldb) po [ekEvent.attendees objectAtIndex:3]
$20 = 0x208c1220 EKAttendee <0x208c1220> {UUID = CCD17C5E-FCB5-4BC9-8D9E-7E957B20025D;
name= ----- -----; email = --------wa@me.com; status = 2; role = 0; type = 1}
(lldb) print [(EKParticipant *)[ekEvent.attendees objectAtIndex:3] isCurrentUser]
(BOOL) $15 = NO
(lldb) po ekEvent.organizer
$19 = 0x20b720e0 EKOrganizer <0x20b720e0> {UUID = FD0E434D-2C9F-4A6E-98DC-
7FA6F27C3D1E; name = ----- -----; email = --------wa@me.com; isSelf = 1}
(lldb) print ekEvent.organizer.isCurrentUser
(BOOL) $16 = YES
Organiser of the event is not by default in the attendees list, you explicitly add him as attendees.
Organiser is considered different from attendees and is depicted with attribute organiser. If you use that object to access isCurrentUser it will provide you value Yes.
If you explicitly add the organiser email id as attendee it is considered different user, for that you need to compare attendees URL and check.
Example : User a..@a.com organised a meeting or event and invited b..@b.com
then in attendees you will have only b..@b.com and a..@a.com will be available as organiser.
In case you add a..@a.com as attendee also then its property isCurrentUser is No and you can check by comparing the attendees URL string itself with organiser.
Yes you can determine which attendee of ekevent is the current user.
I found a way to make isCurrentUser
work for any participant.
According to https://stackoverflow.com/a/17222036/3683845 we can get attendee's email with EKParticipant.URL.resourceSpecifier
Well, you will get right email expect two guys. The one is the organizer, another is current user who uses the AppleID on this device.(If the event is an invitation)
When you access these two guys, their resourceSpecifier
is something like
/aMTA3MDAxMjE0MzEwNzAwMb6Y7GrNw2OCqzA8gkpxsctNZJxrzpebHm/principal/
not the email format.
UPDATE
It works for my iPhone on 9.3.2.
I can distinguish which one is current user in attendees.
When talk to event's organizer, if there is no invitee the organizer will be nil meaning this event is created by current user but organizer.isCurrentUser
will be NO
. Because organizer
is nil
.
When user invites some others to attend this event, organizer
will be not nil and its isCurrentUser
will be YES