190
These are confidential sessions—please refrain from streaming, blogging, or taking pictures Session 304 Jeffrey Harris, Matt Lanter Interpersonal Apps Events and Reminders in Event Kit Aaron Thompson, Scott Adler iOS Apps & Frameworks

Session 304 - Events and Reminders in Event Kit

Embed Size (px)

DESCRIPTION

Session 304 - Events and Reminders in Event Kit

Citation preview

Page 1: Session 304 - Events and Reminders in Event Kit

These are confidential sessions—please refrain from streaming, blogging, or taking pictures

Session 304Jeffrey Harris, Matt LanterInterpersonal Apps

Events and Reminders in Event Kit

Aaron Thompson, Scott AdleriOS Apps & Frameworks

Page 2: Session 304 - Events and Reminders in Event Kit

Agenda

Page 3: Session 304 - Events and Reminders in Event Kit

Agenda

• Calendar events

Page 4: Session 304 - Events and Reminders in Event Kit

Agenda

• Calendar events • Reminders

Page 5: Session 304 - Events and Reminders in Event Kit

Agenda

• Calendar events • Reminders• Event Kit data isolation

Page 6: Session 304 - Events and Reminders in Event Kit

Agenda

• Calendar events • Reminders• Event Kit data isolation• Calendar Store on OS X

Page 7: Session 304 - Events and Reminders in Event Kit

Working with Calendar Events

Page 8: Session 304 - Events and Reminders in Event Kit

Calendar Events in Event Kit

Page 9: Session 304 - Events and Reminders in Event Kit

Calendar Events Are Important

Page 10: Session 304 - Events and Reminders in Event Kit

Calendar Events Are Important

Page 11: Session 304 - Events and Reminders in Event Kit

AwesomeWedding

Calendar Events Are Important

Page 12: Session 304 - Events and Reminders in Event Kit

AwesomeWedding

Calendar Events Are Important

Page 13: Session 304 - Events and Reminders in Event Kit

Calendar Events Are Important

Page 14: Session 304 - Events and Reminders in Event Kit

Calendar Events Are Important

• Increase user interaction

Page 15: Session 304 - Events and Reminders in Event Kit

Calendar Events Are Important

• Increase user interaction• Link back to your application

Page 16: Session 304 - Events and Reminders in Event Kit

Calendar Events Are Important

• Increase user interaction• Link back to your application• Add alarms

Page 17: Session 304 - Events and Reminders in Event Kit

Event Kit Elements

Page 18: Session 304 - Events and Reminders in Event Kit

Event Kit Elements

Page 19: Session 304 - Events and Reminders in Event Kit

Event Kit Elements

Page 20: Session 304 - Events and Reminders in Event Kit

Event Kit Elements

EKCalendar

EKEvent EKEvent

Page 21: Session 304 - Events and Reminders in Event Kit

Event Kit Elements

EKCalendar

EKEvent EKEvent

Page 22: Session 304 - Events and Reminders in Event Kit

Event Kit Elements

EKCalendar

EKEvent EKEvent

Page 23: Session 304 - Events and Reminders in Event Kit

Event Kit Elements

EKCalendar

EKEvent EKEventReminders

Calendar Events

Page 24: Session 304 - Events and Reminders in Event Kit

Event Kit Elements

EKCalendar

EKEvent EKEventReminders

Calendar Events

Page 25: Session 304 - Events and Reminders in Event Kit

Event Kit Elements

EKCalendar

EKEvent EKEventReminders

Calendar Events

Page 26: Session 304 - Events and Reminders in Event Kit

Event Kit Elements

EKCalendar

EKEvent EKEvent

Page 27: Session 304 - Events and Reminders in Event Kit

EKEventStoreAccessing a User’s Calendar Data

EKCalendar

EKEvent EKEvent

Page 28: Session 304 - Events and Reminders in Event Kit

EKEventStore

EKEventStore

Accessing a User’s Calendar Data

EKCalendar

EKEvent EKEvent

Page 29: Session 304 - Events and Reminders in Event Kit

EKEventStore

EKEventStore• Connection to calendar data persistence

Accessing a User’s Calendar Data

EKCalendar

EKEvent EKEvent

Page 30: Session 304 - Events and Reminders in Event Kit

EKEventStore

EKEventStore• Connection to calendar data persistence

• Should be long lived

Accessing a User’s Calendar Data

EKCalendar

EKEvent EKEvent

Page 31: Session 304 - Events and Reminders in Event Kit

EKEventStore

EKEventStore• Connection to calendar data persistence

• Should be long lived• Specify events or reminders

Accessing a User’s Calendar Data

EKCalendar

EKEvent EKEvent

Page 32: Session 304 - Events and Reminders in Event Kit

EKEventStore

EKEventStore• Connection to calendar data persistence

• Should be long lived• Specify events or reminders

Accessing a User’s Calendar Data

EKCalendar

EKEvent EKEvent

Page 33: Session 304 - Events and Reminders in Event Kit

EKCalendar

Page 34: Session 304 - Events and Reminders in Event Kit

EKCalendar

Page 35: Session 304 - Events and Reminders in Event Kit

OS X iOS

EKCalendarEKCalendar

CalendarsEKCalendar

Page 36: Session 304 - Events and Reminders in Event Kit

OS X iOS

EKCalendarEKCalendar

CalendarsEKCalendar

sourcetitlecolorallowedEntityTypes

Page 37: Session 304 - Events and Reminders in Event Kit

OS X iOS

EKCalendarEKCalendar

CalendarsEKCalendar

sourcetitlecolorallowedEntityTypes

Page 38: Session 304 - Events and Reminders in Event Kit

OS X iOS

EKCalendarEKCalendar

CalendarsEKCalendar

sourcetitlecolorallowedEntityTypes

Page 39: Session 304 - Events and Reminders in Event Kit

OS X iOS

EKCalendarEKCalendar

CalendarsEKCalendar

sourcetitlecolorallowedEntityTypes

Page 40: Session 304 - Events and Reminders in Event Kit

OS X iOS

EKCalendarEKCalendar

CalendarsEKCalendar

sourcetitlecolorallowedEntityTypes

Page 41: Session 304 - Events and Reminders in Event Kit

OS X iOS

EKCalendarEKCalendar

CalendarsEKCalendar

sourcetitlecolorallowedEntityTypes

Page 42: Session 304 - Events and Reminders in Event Kit

Calendar EventsEKEvent

OS X iOS

titlelocationallDaystartDateendDatetimeZonecalendar alarms

EKEvent

Page 43: Session 304 - Events and Reminders in Event Kit

Fetching Events for a Week

Page 44: Session 304 - Events and Reminders in Event Kit

// Fetch and print all Events this weekEKEventStore *store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskEvent];

Fetching Events for a Week

Page 45: Session 304 - Events and Reminders in Event Kit

// Fetch and print all Events this weekEKEventStore *store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskEvent];

Fetching Events for a Week

Page 46: Session 304 - Events and Reminders in Event Kit

Fetching Events for a Week

// Fetch and print all Events this weekEKEventStore *store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskEvent];

NSArray *eventCalendars = [store calendarsForEntityType:EKEntityTypeEvent];

Page 47: Session 304 - Events and Reminders in Event Kit

Fetching Events for a Week

// Fetch and print all Events this weekEKEventStore *store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskEvent];

NSArray *eventCalendars = [store calendarsForEntityType:EKEntityTypeEvent];

Page 48: Session 304 - Events and Reminders in Event Kit

// Fetch and print all Events this weekEKEventStore *store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskEvent];

NSArray *eventCalendars = [store calendarsForEntityType:EKEntityTypeEvent];NSDate *monday, *sunday;... // determine monday and sunday for the current weekNSPredicate *predicate;predicate = [store predicateForEventsWithStartDate:monday endDate:sunday calendars:eventCalendars];

Fetching Events for a Week

Page 49: Session 304 - Events and Reminders in Event Kit

// Fetch and print all Events this weekEKEventStore *store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskEvent];

NSArray *eventCalendars = [store calendarsForEntityType:EKEntityTypeEvent];NSDate *monday, *sunday;... // determine monday and sunday for the current weekNSPredicate *predicate;predicate = [store predicateForEventsWithStartDate:monday endDate:sunday calendars:eventCalendars];

Fetching Events for a Week

Page 50: Session 304 - Events and Reminders in Event Kit

// Fetch and print all Events this weekEKEventStore *store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskEvent];

NSArray *eventCalendars = [store calendarsForEntityType:EKEntityTypeEvent];NSDate *monday, *sunday;... // determine monday and sunday for the current weekNSPredicate *predicate;predicate = [store predicateForEventsWithStartDate:monday endDate:sunday calendars:eventCalendars];NSArray *events = [store eventsMatchingPredicate:predicate];NSLog(@”Events this week:”);for (EKEvent *event in events) { NSLog(@”%@ - starts at %@”, event.title, event.startDate);}

Fetching Events for a Week

Page 51: Session 304 - Events and Reminders in Event Kit

// Fetch and print all Events this weekEKEventStore *store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskEvent];

NSArray *eventCalendars = [store calendarsForEntityType:EKEntityTypeEvent];NSDate *monday, *sunday;... // determine monday and sunday for the current weekNSPredicate *predicate;predicate = [store predicateForEventsWithStartDate:monday endDate:sunday calendars:eventCalendars];NSArray *events = [store eventsMatchingPredicate:predicate];NSLog(@”Events this week:”);for (EKEvent *event in events) { NSLog(@”%@ - starts at %@”, event.title, event.startDate);}

Fetching Events for a Week

Page 52: Session 304 - Events and Reminders in Event Kit

DemoPoker night voting

Matt LanterInterpersonal Apps

Page 53: Session 304 - Events and Reminders in Event Kit
Page 54: Session 304 - Events and Reminders in Event Kit
Page 55: Session 304 - Events and Reminders in Event Kit
Page 56: Session 304 - Events and Reminders in Event Kit
Page 57: Session 304 - Events and Reminders in Event Kit
Page 58: Session 304 - Events and Reminders in Event Kit
Page 59: Session 304 - Events and Reminders in Event Kit
Page 60: Session 304 - Events and Reminders in Event Kit
Page 61: Session 304 - Events and Reminders in Event Kit

Model

Page 62: Session 304 - Events and Reminders in Event Kit

Model

• Fetch calendars

Page 63: Session 304 - Events and Reminders in Event Kit

Model

• Fetch calendars• Fetch calendar events

Page 64: Session 304 - Events and Reminders in Event Kit

Model

• Fetch calendars• Fetch calendar events• Create an event

Page 65: Session 304 - Events and Reminders in Event Kit

Model

• Fetch calendars• Fetch calendar events• Create an event• Vote on an event

Page 66: Session 304 - Events and Reminders in Event Kit

DemoPoker night voting

Matt LanterInterpersonal Apps

Page 67: Session 304 - Events and Reminders in Event Kit

Model

Model

Page 68: Session 304 - Events and Reminders in Event Kit

Reminders in Event Kit

Aaron ThompsonGregorian Mixologist

Page 69: Session 304 - Events and Reminders in Event Kit

Reminders Everywhere

Page 70: Session 304 - Events and Reminders in Event Kit
Page 71: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

Page 72: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

Page 73: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

Page 74: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

EKEventStore *store = [[EKEventStore alloc]! ! ! ! initWithAccessToEntityTypes:EKEntityMaskReminder];

Page 75: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

EKEventStore *store = [[EKEventStore alloc]! ! ! ! initWithAccessToEntityTypes:EKEntityMaskReminder];

Page 76: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

EKEventStore *store = [[EKEventStore alloc]! ! ! ! initWithAccessToEntityTypes:EKEntityMaskReminder];EKReminder *reminder = [EKReminder reminderWithEventStore:store];

Page 77: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

EKEventStore *store = [[EKEventStore alloc]! ! ! ! initWithAccessToEntityTypes:EKEntityMaskReminder];EKReminder *reminder = [EKReminder reminderWithEventStore:store];

Page 78: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

EKEventStore *store = [[EKEventStore alloc]! ! ! ! initWithAccessToEntityTypes:EKEntityMaskReminder];EKReminder *reminder = [EKReminder reminderWithEventStore:store];reminder.title = @”Give my cat a bath”

Page 79: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

EKEventStore *store = [[EKEventStore alloc]! ! ! ! initWithAccessToEntityTypes:EKEntityMaskReminder];EKReminder *reminder = [EKReminder reminderWithEventStore:store];reminder.title = @”Give my cat a bath”

Page 80: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

EKEventStore *store = [[EKEventStore alloc]! ! ! ! initWithAccessToEntityTypes:EKEntityMaskReminder];EKReminder *reminder = [EKReminder reminderWithEventStore:store];reminder.title = @”Give my cat a bath”reminder.calendar = [store defaultCalendarForNewReminders]

Page 81: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

EKEventStore *store = [[EKEventStore alloc]! ! ! ! initWithAccessToEntityTypes:EKEntityMaskReminder];EKReminder *reminder = [EKReminder reminderWithEventStore:store];reminder.title = @”Give my cat a bath”reminder.calendar = [store defaultCalendarForNewReminders]

Page 82: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

EKEventStore *store = [[EKEventStore alloc]! ! ! ! initWithAccessToEntityTypes:EKEntityMaskReminder];EKReminder *reminder = [EKReminder reminderWithEventStore:store];reminder.title = @”Give my cat a bath”reminder.calendar = [store defaultCalendarForNewReminders]NSError *err = nil;[store saveReminder:reminder commit:YES error:&err];

Page 83: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath.”

EKEventStore *store = [[EKEventStore alloc]! ! ! ! initWithAccessToEntityTypes:EKEntityMaskReminder];EKReminder *reminder = [EKReminder reminderWithEventStore:store];reminder.title = @”Give my cat a bath”reminder.calendar = [store defaultCalendarForNewReminders]NSError *err = nil;[store saveReminder:reminder commit:YES error:&err];

Page 84: Session 304 - Events and Reminders in Event Kit

Time-Based Reminders

Page 85: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”

Page 86: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”

Page 87: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”NSDate *alarmDate = ; // Tomorrow at 4 PMEKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];

Page 88: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”NSDate *alarmDate = ; // Tomorrow at 4 PMEKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];

Page 89: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”NSDate *alarmDate = ; // Tomorrow at 4 PMEKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];

Page 90: Session 304 - Events and Reminders in Event Kit

“Bad dates.” - Raiders of the Lost ArkDate Math

Page 91: Session 304 - Events and Reminders in Event Kit
Page 92: Session 304 - Events and Reminders in Event Kit

86, 400

Page 93: Session 304 - Events and Reminders in Event Kit

86, 40060

seconds60

minutes24hours

× ×

Page 94: Session 304 - Events and Reminders in Event Kit

86, 40060

seconds60

minutes24hours

× ×

Page 95: Session 304 - Events and Reminders in Event Kit

86, 40060

seconds60

minutes24hours

× ×

May be wrong twice per year!

Page 96: Session 304 - Events and Reminders in Event Kit

Tomorrow at 4 pm

NSCalendar *calendar = [NSCalendar gregorianCalendar];

Page 97: Session 304 - Events and Reminders in Event Kit

Tomorrow at 4 pm

NSCalendar *calendar = [NSCalendar gregorianCalendar];

Page 98: Session 304 - Events and Reminders in Event Kit

Tomorrow at 4 pm

NSCalendar *calendar = [NSCalendar gregorianCalendar];NSDateComponents *oneDayComponents = [[NSDateComponents alloc] init];oneDayComponents.day = 1;

Page 99: Session 304 - Events and Reminders in Event Kit

Tomorrow at 4 pm

NSCalendar *calendar = [NSCalendar gregorianCalendar];NSDateComponents *oneDayComponents = [[NSDateComponents alloc] init];oneDayComponents.day = 1;

Page 100: Session 304 - Events and Reminders in Event Kit

Tomorrow at 4 pm

NSCalendar *calendar = [NSCalendar gregorianCalendar];NSDateComponents *oneDayComponents = [[NSDateComponents alloc] init];oneDayComponents.day = 1;NSDate *tomorrow = [calendar dateByAddingComponents:oneDayComponents toDate:[NSDate date] options:nil];

Page 101: Session 304 - Events and Reminders in Event Kit

Tomorrow at 4 pm

NSCalendar *calendar = [NSCalendar gregorianCalendar];NSDateComponents *oneDayComponents = [[NSDateComponents alloc] init];oneDayComponents.day = 1;NSDate *tomorrow = [calendar dateByAddingComponents:oneDayComponents toDate:[NSDate date] options:nil];

Page 102: Session 304 - Events and Reminders in Event Kit

Tomorrow at 4 pm

NSCalendar *calendar = [NSCalendar gregorianCalendar];NSDateComponents *oneDayComponents = [[NSDateComponents alloc] init];oneDayComponents.day = 1;NSDate *tomorrow = [calendar dateByAddingComponents:oneDayComponents toDate:[NSDate date] options:nil];NSUInteger unitFlags = NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;NSDateComponents *tomorrowAt4PM = [calendar components:unitFlags fromDate:tomorrow];tomorrowAt4PM.hour = 16;tomorrowAt4PM.minute = 0;tomorrowAt4PM.second = 0;

Page 103: Session 304 - Events and Reminders in Event Kit

Tomorrow at 4 pm

NSCalendar *calendar = [NSCalendar gregorianCalendar];NSDateComponents *oneDayComponents = [[NSDateComponents alloc] init];oneDayComponents.day = 1;NSDate *tomorrow = [calendar dateByAddingComponents:oneDayComponents toDate:[NSDate date] options:nil];NSUInteger unitFlags = NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;NSDateComponents *tomorrowAt4PM = [calendar components:unitFlags fromDate:tomorrow];tomorrowAt4PM.hour = 16;tomorrowAt4PM.minute = 0;tomorrowAt4PM.second = 0;

Page 104: Session 304 - Events and Reminders in Event Kit

Tomorrow at 4 pm

NSCalendar *calendar = [NSCalendar gregorianCalendar];NSDateComponents *oneDayComponents = [[NSDateComponents alloc] init];oneDayComponents.day = 1;NSDate *tomorrow = [calendar dateByAddingComponents:oneDayComponents toDate:[NSDate date] options:nil];NSUInteger unitFlags = NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;NSDateComponents *tomorrowAt4PM = [calendar components:unitFlags fromDate:tomorrow];tomorrowAt4PM.hour = 16;tomorrowAt4PM.minute = 0;tomorrowAt4PM.second = 0;NSDate *alarmDate = [calendar dateFromComponents:tomorrowAt4PM];

Page 105: Session 304 - Events and Reminders in Event Kit

Tomorrow at 4 pm

NSCalendar *calendar = [NSCalendar gregorianCalendar];NSDateComponents *oneDayComponents = [[NSDateComponents alloc] init];oneDayComponents.day = 1;NSDate *tomorrow = [calendar dateByAddingComponents:oneDayComponents toDate:[NSDate date] options:nil];NSUInteger unitFlags = NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;NSDateComponents *tomorrowAt4PM = [calendar components:unitFlags fromDate:tomorrow];tomorrowAt4PM.hour = 16;tomorrowAt4PM.minute = 0;tomorrowAt4PM.second = 0;NSDate *alarmDate = [calendar dateFromComponents:tomorrowAt4PM];

Page 106: Session 304 - Events and Reminders in Event Kit

“Bad dates.” - Raiders of the Lost ArkDate Math

Page 107: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”NSDate *alarmDate = …; // Tomorrow at 4 PMEKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];

Page 108: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”NSDate *alarmDate = …; // Tomorrow at 4 PMEKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];

Page 109: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”NSDate *alarmDate = …; // Tomorrow at 4 PMEKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];[reminder addAlarm:alarm];

Page 110: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”NSDate *alarmDate = …; // Tomorrow at 4 PMEKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];[reminder addAlarm:alarm];

Page 111: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”NSDate *alarmDate = …; // Tomorrow at 4 PMEKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];[reminder addAlarm:alarm];reminder.dueDateComponents = …; // Tomorrow at 4 PM

Page 112: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”NSDate *alarmDate = …; // Tomorrow at 4 PMEKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];[reminder addAlarm:alarm];reminder.dueDateComponents = …; // Tomorrow at 4 PM

Page 113: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”NSDate *alarmDate = …; // Tomorrow at 4 PMEKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];[reminder addAlarm:alarm];reminder.dueDateComponents = …; // Tomorrow at 4 PM[store saveReminder:reminder commit:YES error:&err];

Page 114: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Tomorrow at 4 pm.”NSDate *alarmDate = …; // Tomorrow at 4 PMEKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];[reminder addAlarm:alarm];reminder.dueDateComponents = …; // Tomorrow at 4 PM[store saveReminder:reminder commit:YES error:&err];

Page 115: Session 304 - Events and Reminders in Event Kit

Location-Based Reminders

Page 116: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”

Page 117: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”

Page 118: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];

Page 119: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];

Page 120: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];

Page 121: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];

Page 122: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];location.geoLocation = geoLocation;

Page 123: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];location.geoLocation = geoLocation;

Page 124: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];location.geoLocation = geoLocation;

EKAlarm *alarm = [[EKAlarm alloc] init];

Page 125: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];location.geoLocation = geoLocation;

EKAlarm *alarm = [[EKAlarm alloc] init];

Page 126: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];location.geoLocation = geoLocation;

EKAlarm *alarm = [[EKAlarm alloc] init];alarm.structuredLocation = location;alarm.proximity = EKAlarmProximityLeave;

Page 127: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];location.geoLocation = geoLocation;

EKAlarm *alarm = [[EKAlarm alloc] init];alarm.structuredLocation = location;alarm.proximity = EKAlarmProximityLeave;

Page 128: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];location.geoLocation = geoLocation;

EKAlarm *alarm = [[EKAlarm alloc] init];alarm.structuredLocation = location;alarm.proximity = EKAlarmProximityLeave;[reminder addAlarm:alarm];

Page 129: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];location.geoLocation = geoLocation;

EKAlarm *alarm = [[EKAlarm alloc] init];alarm.structuredLocation = location;alarm.proximity = EKAlarmProximityLeave;[reminder addAlarm:alarm];

Page 130: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];location.geoLocation = geoLocation;

EKAlarm *alarm = [[EKAlarm alloc] init];alarm.structuredLocation = location;alarm.proximity = EKAlarmProximityLeave;[reminder addAlarm:alarm];[store saveReminder:reminder commit:YES error:&err];

Page 131: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Pick up a Chain Mail Suit When I Leave Work.”EKStructuredLocation *location;location = [EKStructuredLocation locationWithTitle:@”Work”];CLLocation *geoLocation; // Can obtain from CLGeocodergeoLocation = [[CLLocation alloc] initWithLatitude:37.332 longitude:-122.03];location.geoLocation = geoLocation;

EKAlarm *alarm = [[EKAlarm alloc] init];alarm.structuredLocation = location;alarm.proximity = EKAlarmProximityLeave;[reminder addAlarm:alarm];[store saveReminder:reminder commit:YES error:&err];

Page 132: Session 304 - Events and Reminders in Event Kit

Recurring Reminders

Page 133: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Every Month.”

Page 134: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Every Month.”

Page 135: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Every Month.”EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyMonthly interval:1 end:nil];

Page 136: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Every Month.”EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyMonthly interval:1 end:nil];

Page 137: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Every Month.”EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyMonthly interval:1 end:nil];[reminder addRecurrenceRule:rule];

Page 138: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Every Month.”EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyMonthly interval:1 end:nil];[reminder addRecurrenceRule:rule];

Page 139: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Every Month.”EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyMonthly interval:1 end:nil];[reminder addRecurrenceRule:rule];NSDateComponents *componentsForNow = …; // Current timereminder.startDateComponents = componentsForNow;

Page 140: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Every Month.”EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyMonthly interval:1 end:nil];[reminder addRecurrenceRule:rule];NSDateComponents *componentsForNow = …; // Current timereminder.startDateComponents = componentsForNow;

Page 141: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Every Month.”EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyMonthly interval:1 end:nil];[reminder addRecurrenceRule:rule];NSDateComponents *componentsForNow = …; // Current timereminder.startDateComponents = componentsForNow;NSError *error = nil;[store saveReminder:reminder commit:YES error:&error];

Page 142: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Every Month.”EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyMonthly interval:1 end:nil];[reminder addRecurrenceRule:rule];NSDateComponents *componentsForNow = …; // Current timereminder.startDateComponents = componentsForNow;NSError *error = nil;[store saveReminder:reminder commit:YES error:&error];

Page 143: Session 304 - Events and Reminders in Event Kit

“Siri, Remind Me to Give My Cat a Bath Every Month.”EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyMonthly interval:1 end:nil];[reminder addRecurrenceRule:rule];NSDateComponents *componentsForNow = …; // Current timereminder.startDateComponents = componentsForNow;NSError *error = nil;[store saveReminder:reminder commit:YES error:&error];

When one is completed, next is generated

Page 144: Session 304 - Events and Reminders in Event Kit

Marking Reminders Complete

Page 145: Session 304 - Events and Reminders in Event Kit

Marking Reminders Complete

Page 146: Session 304 - Events and Reminders in Event Kit

Marking Reminders Complete

Page 147: Session 304 - Events and Reminders in Event Kit

Marking Reminders Complete

reminder.completed = YES;NSError *error = nil;[store saveReminder:reminder commit:YES error:&error];

Page 148: Session 304 - Events and Reminders in Event Kit

Marking Reminders Complete

reminder.completed = YES;NSError *error = nil;[store saveReminder:reminder commit:YES error:&error];

Page 149: Session 304 - Events and Reminders in Event Kit

Marking Reminders Complete

reminder.completed = YES;NSError *error = nil;[store saveReminder:reminder commit:YES error:&error];

Page 150: Session 304 - Events and Reminders in Event Kit

Setting a Completion Date

Page 151: Session 304 - Events and Reminders in Event Kit

Setting a Completion Date

Page 152: Session 304 - Events and Reminders in Event Kit

•Automatically set to the current time when you setreminder.completed = YES;

Setting a Completion Date

Page 153: Session 304 - Events and Reminders in Event Kit

•Automatically set to the current time when you setreminder.completed = YES;

•You can set it to any date usingreminder.completionDate = date;

Setting a Completion Date

Page 154: Session 304 - Events and Reminders in Event Kit

“Remind me how that API works.”Reminders API Summary

Page 155: Session 304 - Events and Reminders in Event Kit

“Remind me how that API works.”Reminders API Summary

• Time-based reminders use EKAlarm with absolute time

Page 156: Session 304 - Events and Reminders in Event Kit

“Remind me how that API works.”Reminders API Summary

• Time-based reminders use EKAlarm with absolute time

• Location-based reminders use EKAlarm with structured location

Page 157: Session 304 - Events and Reminders in Event Kit

“Remind me how that API works.”Reminders API Summary

• Time-based reminders use EKAlarm with absolute time

• Location-based reminders use EKAlarm with structured location

• Recurring reminders use EKRecurrenceRule

Page 158: Session 304 - Events and Reminders in Event Kit

“Remind me how that API works.”Reminders API Summary

• Time-based reminders use EKAlarm with absolute time

• Location-based reminders use EKAlarm with structured location

• Recurring reminders use EKRecurrenceRule

• Mark as done using completed and completionDate properties

Page 159: Session 304 - Events and Reminders in Event Kit

Integrating Reminders

Scott AdlerPerson of Interest

Page 160: Session 304 - Events and Reminders in Event Kit
Page 161: Session 304 - Events and Reminders in Event Kit
Page 162: Session 304 - Events and Reminders in Event Kit

DemoRecipes 2: Electric Boogaloo

Scott AdlerPerson of Interest

Page 163: Session 304 - Events and Reminders in Event Kit

Event Kit Data Isolation

Page 164: Session 304 - Events and Reminders in Event Kit

Talk to the Event Kit Data Isolation

Page 165: Session 304 - Events and Reminders in Event Kit

Talk to the Event Kit Data Isolation

• User is prompted for access when EKEventStore is instantiated

Page 166: Session 304 - Events and Reminders in Event Kit

Talk to the Event Kit Data Isolation

• User is prompted for access when EKEventStore is instantiated

• Your code is not blocked when displaying access prompt

Page 167: Session 304 - Events and Reminders in Event Kit

Talk to the Event Kit Data Isolation

• User is prompted for access when EKEventStore is instantiated

• Your code is not blocked when displaying access prompt

• EKEventStoreChangedNotification fires when authorization changes

Page 168: Session 304 - Events and Reminders in Event Kit

Talk to the Event Kit Data Isolation

• User is prompted for access when EKEventStore is instantiated

• Your code is not blocked when displaying access prompt

• EKEventStoreChangedNotification fires when authorization changes

• Usage description stored in Info.plist

Page 169: Session 304 - Events and Reminders in Event Kit

DemoAdapting existing code for privacy

Scott AdlerPerson of Interest

Page 170: Session 304 - Events and Reminders in Event Kit

Calendar Store on OS X

Jeffrey HarrisInterpersonal Apps

Page 171: Session 304 - Events and Reminders in Event Kit
Page 172: Session 304 - Events and Reminders in Event Kit

Calendar Store Is Deprecated

Page 173: Session 304 - Events and Reminders in Event Kit

Calendar Store and Event Kit Parity

CalCalendarStore

CalCalendar

CalEvent

CalTask

Page 174: Session 304 - Events and Reminders in Event Kit

Calendar Store and Event Kit Parity

CalCalendarStore

CalCalendar

CalEvent

CalTask

EKEventStore

EKCalendar

EKEvent

EKReminder

Page 175: Session 304 - Events and Reminders in Event Kit

EKEventStore *store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskEvent]; NSArray *eventCalendars = [store calendarsForEntityType:EKEntityTypeEvent]; NSDate *monday, *sunday; ... // determine monday and sunday for the current week NSPredicate *predicate; predicate = [store predicateForEventsWithStartDate:monday endDate:sunday calendars:eventCalendars];

NSArray *events = [store eventsMatchingPredicate:predicate]; NSLog(@”Events this week:”); for (EKEvent *event in events) { NSLog(@”%@ - starts at %@”, event.title, event.startDate); }

Using EventKitFetching Events for a Week

Page 176: Session 304 - Events and Reminders in Event Kit

CalCalendarStore *store = [CalCalendarStore defaultCalendarStore];

NSArray *eventCalendars = [store calendars]; NSDate *monday, *sunday; ... // determine monday and sunday for the current week NSPredicate *predicate; predicate = [store eventPredicateWithStartDate :monday endDate:sunday calendars:eventCalendars];

NSArray *events = [store eventsWithPredicate :predicate]; NSLog(@”Events this week:”); for (CalEvent *event in events) { NSLog(@”%@ - starts at %@”, event.title, event.startDate); }

Using CalendarStoreFetching Events for a Week

Page 177: Session 304 - Events and Reminders in Event Kit

EKEventStore *store = [[EKEventStore alloc] initWithAccessToEntityTypes:EKEntityMaskEvent]; NSArray *eventCalendars = [store calendarsForEntityType:EKEntityTypeEvent]; NSDate *monday, *sunday; ... // determine monday and sunday for the current week NSPredicate *predicate; predicate = [store predicateForEventsWithStartDate:monday endDate:sunday calendars:eventCalendars];

NSArray *events = [store eventsMatchingPredicate:predicate]; NSLog(@”Events this week:”); for (EKEvent *event in events) { NSLog(@”%@ - starts at %@”, event.title, event.startDate); }

Using EventKitFetching Events for a Week

Page 178: Session 304 - Events and Reminders in Event Kit

Event Kit Benefits

Page 179: Session 304 - Events and Reminders in Event Kit

Event Kit Benefits

• Works across iOS and OS X

Page 180: Session 304 - Events and Reminders in Event Kit

Event Kit Benefits

• Works across iOS and OS X• Has properties not available in Calendar Store

Page 181: Session 304 - Events and Reminders in Event Kit

Event Kit Benefits

• Works across iOS and OS X• Has properties not available in Calendar Store

■ Time zones for event start

Page 182: Session 304 - Events and Reminders in Event Kit

Event Kit Benefits

• Works across iOS and OS X• Has properties not available in Calendar Store

■ Time zones for event start■ Types of items allowed in a calendar (events, reminders, or both)

Page 183: Session 304 - Events and Reminders in Event Kit

Previous Event Kit Presentation

• Calendar Integration with Event Kithttps://developer.apple.com/videos/wwdc/2010/?id=136

Page 184: Session 304 - Events and Reminders in Event Kit

Related Sessions

Privacy Support in iOS and OS X Pacific HeightsThursday 3:15PM

Staying on Track with Location Services Nob HillWednesday 2:00PM

Internationalization Tips and Tricks MarinaFriday 10:15AM

Page 185: Session 304 - Events and Reminders in Event Kit

Labs

Event Kit and Reminders Lab App Services Lab AThursday 9:00AM

Core Location Lab App Services Lab BWednesday 3:15PM

Internationalization Lab App Services Lab AFriday 11:30AM

Page 186: Session 304 - Events and Reminders in Event Kit

Summary

• Events and reminders now available on iOS and OS X• It’s easy!

Page 187: Session 304 - Events and Reminders in Event Kit
Page 188: Session 304 - Events and Reminders in Event Kit

The last 3 slides after the logo are intentionally left blank for all presentations.

Page 189: Session 304 - Events and Reminders in Event Kit

The last 3 slides after the logo are intentionally left blank for all presentations.

Page 190: Session 304 - Events and Reminders in Event Kit

The last 3 slides after the logo are intentionally left blank for all presentations.