Nilsymbol
Nilsymbol

Reputation: 525

Accessing events in "Events Found in Mail" calendar

I'm trying to access events that are created automatically from emails with the new proactive assistant feature found in iOS 9. The events are displayed in the "Events Found in Mail" Calendar.

To access these I am doing the following

self.eventStore.requestAccessToEntityType(.Event, completion: { (granted, error) -> Void in

    let predicate = eventStore.predicateForEventsWithStartDate(NSDate(timeIntervalSince1970: timestamp1), endDate: NSDate(timeIntervalSince1970: timestamp2), calendars: nil)
    let events = eventStore.eventsMatchingPredicate(predicate)

}

However the events in this calendar are not listed. Is this a limitation from Apple or can I access them in any other way?

enter image description here

Upvotes: 8

Views: 1263

Answers (2)

66o
66o

Reputation: 756

I was able to ask this question to an apple engineer and their answer is that they do not expose this calendar for privacy reasons. They want an user to add an event parsed from mail to one of their normal calendars to confirm they want to expose it to other apps and that is why this calendar is not visible when doing usual

 let calendars = store.calendarsForEntityType(EKEntityTypeEvent)

Upvotes: 2

alex1511
alex1511

Reputation: 445

I am unsure if this is a limitation by Apple but in general if you know the name of a calendar you can access it like this :)

func yourFunc(store: EKEventStore) {

    let calendars = store.calendarsForEntityType(EKEntityTypeEvent)
        as! [EKCalendar]

    for calendar in calendars {

        if calendar.title == "Events Found in Mail" {
       //Do something!}}}

Try something along these lines!

Upvotes: -1

Related Questions