4

I have already tried the

if ([event participationStatus] == EKParticipantStatusPending)

and it is working. But the participationStatus of the EKEvent is not exposed and I'm afraid to use it as maybe it will result in a rejection because of a private API.

I have also tried looping through all of the event.attendees but it seems that the EKParticipant isCurrentUser does not give the correct value. It always returns NO

  for (EKParticipant* participant in event.attendees)

  {
    if ([participant isCurrentUser])

    {
      if (participant.participantStatus == EKParticipantStatusPending)

      {
        NSLog(@"NEEDS RESPONSE");
      }

    }

  }
Raymond Brion
  • 332
  • 1
  • 10
  • `isCurrentUser` only works for `[event organizer]`. it will always return NO for participants other than the organizer, as you've observed. – mygzi Mar 30 '14 at 06:05
  • is this the expected behavior? – Raymond Brion Apr 08 '14 at 00:29
  • it is the observed (undocumented) behavior. if you have access to the user's name or email (via other means), you can find the user among the attendees yourself and check status that way. – mygzi Apr 09 '14 at 19:08

1 Answers1

1

Finally I found a tricky 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.

When you access these two guys, their resourceSpecifier is something like

/aMTA3MDAxMjE0MzEwNzAwMb6Y7GrNw2OCqzA8gkpxsctNZJxrzpebHm/principal/

not the email format.

Community
  • 1
  • 1
SeanChense
  • 846
  • 8
  • 14
  • i don't understand how you know if the participant is the current user. – Radu Vlad Sep 02 '16 at 10:05
  • @RaduVlad If you can not get the user's email which means this is current user or organizer. – SeanChense Sep 02 '16 at 10:11
  • I just used the `EKParticipant.URL.resourceSpecifier` method, and I got the email addresses. I used a tentative meeting from one of my google account to another. I never got something like `/aMTA3MDAxMjE0MzEwNzAwMb6Y7GrNw2OCqzA8gkpxsctNZJxrzpebHm/principal/` – Radu Vlad Sep 02 '16 at 10:16
  • @RaduVlad Are you sure your event is created by iCloud not sync from google calendar by iCloud? – SeanChense Sep 02 '16 at 10:20
  • It is probably synced. – Radu Vlad Sep 02 '16 at 10:21
  • :( perhaps that is the reason – Radu Vlad Sep 02 '16 at 10:23
  • but as you stated in http://stackoverflow.com/questions/15628493/ekparticipant-in-eventkit-erroneously-returns-no-for-iscurrentuser-property?rq=1 from IOS 9.3.2 the isCurrentUser property will return accordingly, so this works. thanks. Please update your answer for the others. – Radu Vlad Sep 02 '16 at 10:58