Retrieving Account Information for EKCalendar

I use EventKit in my application and would like to know which account the calendar belongs to.

The iPhone Calendar app displays all calendars grouped by account with the account name, for example, “ myname@me.com ” or “Gmail myname”. Where can I get the names of these accounts?

I can get the EKCalendar list from EKEventStore , and I can get the title of each calendar, but I have no idea where to get the account name from. Is there an official API for this? How else can I get this information? In some applications on the App Store, account names are displayed, so there must be a way (which also slips through the approval process ...)

Thank you Thomas

Update: Somewhere else I found links to private property. Before I start looking for this myself, does anyone know what the name of this property is?

Elsewhere, people also suggested parsing description (including an account), but this is not a very safe or elegant way, so I would like to avoid that.

Update 2: I found out that there is private property (and its name), and it seems to be working fine.

+4
source share
2 answers

I looked at the Apple documentation and the account name does not seem to be accessible through the public API. Your application will be immediately rejected if you use private property, so I believe that these other applications in the App Store use a descriptive analysis method.

I suggest you publish an error report with Apple and request that the account name be accessible through the open API. Until they do (if they do), I think your only option is to analyze the description if you want your app on the App Store

+2
source

With iOS 5.0, you can access EKSource from EKCalendar. You can get the name and type of this source.

  EKEventStore * eventStore = [[EKEventStore alloc] init]; NSArray * calendars = [eventStore calendarsForEntityType:EKEntityTypeEvent]; NSArray * typeNames = [[NSArray alloc] initWithObjects:@"TypeLocal",@"TypeExchange",@"TypeCalDAV",@"TypeMobileMe",@"TypeSubscribed",@"TypeBirthdays", nil]; for (EKCalendar * calendar in calendars) { NSString * calendarTitle = calendar.title; EKSource * source = calendar.source; NSString * accountName = source.title; EKSourceType type = source.sourceType; NSLog(@"%@ : %@ (%@)", calendarTitle, accountName, typeNames[type]); } 

The created log is as follows:

  • CalHotmail: Exchange (TypeExchange)
  • BirthHotmail (read-only): Exchange (TypeExchange)
  • MyCoolAccountCal: Yahoo! (TypeCalDAV)
  • Calendrier: Default (TypeLocal) Birthdays: Other (TypeBirthdays)
  • Calendrier: john.doe@mycooldomain.fr (TypeExchange)
  • ArnoTest: Gmail (TypeCalDAV)
  • Birthdays and Contact Events: Gmail (TypeCalDAV)
0
source

All Articles