Top Banner
© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. #WWDC14 What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer Dan Kurtz Software Engineer
162

What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Jul 17, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

#WWDC14

What’s New in iOS Notifications

Core OS

Session 713 Rhett Dickson Software Engineer

!

Dan Kurtz Software Engineer

Page 2: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Previously in iOS Notifications

User notifications

Silent notifications

Page 3: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsWhat

Daniel Kurtz nowHello world!

Page 4: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsWhat

Daniel Kurtz nowHello world!

Page 5: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsWhat

Daniel Kurtz nowHello world!

Page 6: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsWhat

Daniel Kurtz nowHello world!

Page 7: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsWhere

Page 8: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsWhere

Page 9: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsWhere

Page 10: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsWhere

Page 11: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Where Notifications Come From

APNsApp

Page 12: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Where Notifications Come From

APNs

My App Hello world!

App

Page 13: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Where Notifications Come From

APNsApp

Page 14: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Where Notifications Come From

APNs

My App Hello world!

App

aps { alert: {...}

}

Page 15: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Where Notifications Come From

APNsApp

Page 16: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Where Notifications Come From

APNsApp

Page 17: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Where Notifications Come From

APNsApp

aps { content-available: 1

}

Page 18: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Where Notifications Come From

APNsApp

aps { content-available: 1

}

Content Server

Page 19: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Where Notifications Come From

Page 20: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Today

User Notifications

Notification Actions

Remote Notifications

Location Notifications

Page 21: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User Notifications

Page 22: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsWhat’s new

Must register to use

Require user approval

Page 23: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsRegistering

UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert; !

UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; !

[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];

Page 24: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsRegistering

UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert; !

UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; !

[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];

Page 25: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsRegistering

UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert; !

UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; !

[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];

Page 26: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsRegistering

UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert; !

UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; !

[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];

Page 27: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsRegistering

UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert; !

UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; !

[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];

Page 28: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsRegistering

UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert; !

UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; !

[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings]; “My App” Would Like to Send

You Notifications

Page 29: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsUIApplicationDelegate Callback

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings: (UIUserNotificationSettings *)notificationSettings { !

// user has allowed receiving user notifications of the following types UIUserNotificationType allowedTypes = [notificationSettings types]; !

}

Page 30: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsUIApplicationDelegate Callback

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings: (UIUserNotificationSettings *)notificationSettings { !

// user has allowed receiving user notifications of the following types UIUserNotificationType allowedTypes = [notificationSettings types]; !

}

Page 31: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsUIApplicationDelegate Callback

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings: (UIUserNotificationSettings *)notificationSettings { !

// user has allowed receiving user notifications of the following types UIUserNotificationType allowedTypes = [notificationSettings types]; !

}

Page 32: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsGetting Settings

- (void)getReadyForNotification { // ... !

// check to make sure we still need to show notification UIUserNotificationSettings *currentSettings = [[UIApplication sharedApplication] currentUserNotificationSettings]; !

[self checkSettings:currentSettings]; }

Page 33: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User NotificationsGetting Settings

- (void)getReadyForNotification { // ... !

// check to make sure we still need to show notification UIUserNotificationSettings *currentSettings = [[UIApplication sharedApplication] currentUserNotificationSettings]; !

[self checkSettings:currentSettings]; }

Page 34: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

User Notifications

-[UIApplication registerUserNotificationSettings:] -[UIApplication currentNotificationSettings] +[UIUserNotificationSettings settingsForTypes:categories:]

Page 35: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions

Page 36: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 7

Notification Center Banner

Page 37: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 7

Notification Center Banner

Page 38: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 7

Notification Center Banner

Page 39: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 7

Notification Center Banner

Page 40: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 7

Notification Center Banner

Page 41: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 7

Notification Center Banner

Page 42: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 8

Page 43: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 8

Page 44: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 8

Page 45: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 8

Page 46: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 8

Page 47: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 8

Page 48: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 8

Page 49: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification ActionsIn iOS 8

Page 50: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Using Notification Actions

Register Actions

Push/Schedule Notification

Handle Action

Page 51: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Using Notification Actions

Page 52: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Using Notification Actions

Register Actions

Push/Schedule Notification

Handle Action

Page 53: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Using Notification Actions

Register Actions

Push/Schedule Notification

Handle Action

Page 54: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationActions

UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init]; !

acceptAction.identifier = @"ACCEPT_IDENTIFIER"; !

acceptAction.title = @"Accept"; !

// Given seconds, not minutes, to run in the background acceptAction.activationMode = UIUserNotificationActivationModeBackground; !

acceptAction.destructive = NO; !

// If YES requires passcode, but does not unlock the device acceptAction.authenticationRequired = NO;

Page 55: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationActions

UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init]; !

acceptAction.identifier = @"ACCEPT_IDENTIFIER"; !

acceptAction.title = @"Accept"; !

// Given seconds, not minutes, to run in the background acceptAction.activationMode = UIUserNotificationActivationModeBackground; !

acceptAction.destructive = NO; !

// If YES requires passcode, but does not unlock the device acceptAction.authenticationRequired = NO;

Page 56: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationActions

UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init]; !

acceptAction.identifier = @"ACCEPT_IDENTIFIER"; !

acceptAction.title = @"Accept"; !

// Given seconds, not minutes, to run in the background acceptAction.activationMode = UIUserNotificationActivationModeBackground; !

acceptAction.destructive = NO; !

// If YES requires passcode, but does not unlock the device acceptAction.authenticationRequired = NO;

Page 57: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationActions

UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init]; !

acceptAction.identifier = @"ACCEPT_IDENTIFIER"; !

acceptAction.title = @"Accept"; !

// Given seconds, not minutes, to run in the background acceptAction.activationMode = UIUserNotificationActivationModeBackground; !

acceptAction.destructive = NO; !

// If YES requires passcode, but does not unlock the device acceptAction.authenticationRequired = NO;

Page 58: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationActions

UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init]; !

acceptAction.identifier = @"ACCEPT_IDENTIFIER"; !

acceptAction.title = @"Accept"; !

// Given seconds, not minutes, to run in the background acceptAction.activationMode = UIUserNotificationActivationModeBackground; !

acceptAction.destructive = NO; !

// If YES requires passcode, but does not unlock the device acceptAction.authenticationRequired = NO;

Page 59: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationActions

UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init]; !

acceptAction.identifier = @"ACCEPT_IDENTIFIER"; !

acceptAction.title = @"Accept"; !

// Given seconds, not minutes, to run in the background acceptAction.activationMode = UIUserNotificationActivationModeBackground; !

acceptAction.destructive = NO; !

// If YES requires passcode, but does not unlock the device acceptAction.authenticationRequired = NO;

Page 60: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationActions

UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init]; !

acceptAction.identifier = @"ACCEPT_IDENTIFIER"; !

acceptAction.title = @"Accept"; !

// Given seconds, not minutes, to run in the background acceptAction.activationMode = UIUserNotificationActivationModeBackground; !

acceptAction.destructive = NO; !

// If YES requires passcode, but does not unlock the device acceptAction.authenticationRequired = NO;

Page 61: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationAccept invite

Action Property Value

title @“Accept”

activationMode UIUserNotificationActivationModeBackground

destructive NO

authenticationRequired NO

Accept

Page 62: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationTrash mail

Action Property Value

title @“Trash”

activationMode UIUserNotificationActivationModeBackground

destructive YES

authenticationRequired YES

Trash

Page 63: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationReply to message

Action Property Value

title @“Reply”

activationMode UIUserNotificationActivationModeForeground

destructive NO

authenticationRequired YES*

Reply

Page 64: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationCategories

Category Actions

Invite Accept, Maybe, Decline

New mail Mark as Read, Trash

Tagged Like, Comment, Untag

Page 65: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationCategories

UIMutableUserNotificationCategory *inviteCategory = [[UIMutableUserNotificationCategory alloc] init]; !

inviteCategory.identifier = @"INVITE_CATEGORY"; !

[inviteCategory setActions:@[acceptAction, maybeAction, declineAction] forContext:UIUserNotificationActionContextDefault]; !

Page 66: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationCategories

UIMutableUserNotificationCategory *inviteCategory = [[UIMutableUserNotificationCategory alloc] init]; !

inviteCategory.identifier = @"INVITE_CATEGORY"; !

[inviteCategory setActions:@[acceptAction, maybeAction, declineAction] forContext:UIUserNotificationActionContextDefault]; !

Page 67: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationCategories

UIMutableUserNotificationCategory *inviteCategory = [[UIMutableUserNotificationCategory alloc] init]; !

inviteCategory.identifier = @"INVITE_CATEGORY"; !

[inviteCategory setActions:@[acceptAction, maybeAction, declineAction] forContext:UIUserNotificationActionContextDefault]; !

Page 68: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationCategories

UIMutableUserNotificationCategory *inviteCategory = [[UIMutableUserNotificationCategory alloc] init]; !

inviteCategory.identifier = @"INVITE_CATEGORY"; !

[inviteCategory setActions:@[acceptAction, maybeAction, declineAction] forContext:UIUserNotificationActionContextDefault]; !

Page 69: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions Registration

Page 70: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationCategories

UIMutableUserNotificationCategory *inviteCategory = [[UIMutableUserNotificationCategory alloc] init]; !

inviteCategory.identifier = @"INVITE_CATEGORY"; !

[inviteCategory setActions:@[acceptAction, maybeAction, declineAction] forContext:UIUserNotificationActionContextDefault]; !

[inviteCategory setActions:@[acceptAction, declineAction] forContext:UIUserNotificationActionContextMinimal];

Page 71: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationCategories

UIMutableUserNotificationCategory *inviteCategory = [[UIMutableUserNotificationCategory alloc] init]; !

inviteCategory.identifier = @"INVITE_CATEGORY"; !

[inviteCategory setActions:@[acceptAction, maybeAction, declineAction] forContext:UIUserNotificationActionContextDefault]; !

[inviteCategory setActions:@[acceptAction, declineAction] forContext:UIUserNotificationActionContextMinimal];

Page 72: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions Registration

Page 73: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions Registration

Page 74: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationSettings

NSSet *categories = [NSSet setWithObjects:inviteCategory, alarmCategory, … !

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:categories]; !

[[UIApplication sharedApplication] registerUserNotificationSettings:settings]; !

Page 75: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationSettings

NSSet *categories = [NSSet setWithObjects:inviteCategory, alarmCategory, … !

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:categories]; !

[[UIApplication sharedApplication] registerUserNotificationSettings:settings]; !

Page 76: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationSettings

NSSet *categories = [NSSet setWithObjects:inviteCategory, alarmCategory, … !

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:categories]; !

[[UIApplication sharedApplication] registerUserNotificationSettings:settings]; !

Page 77: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Notification Actions RegistrationSettings

NSSet *categories = [NSSet setWithObjects:inviteCategory, alarmCategory, … !

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:categories]; !

[[UIApplication sharedApplication] registerUserNotificationSettings:settings]; !

Page 78: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Using Notification Actions

Register Actions

Push/Schedule Notification

Handle Action

Page 79: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Using Notification Actions

Register Actions

Push/Schedule Notification

Handle Action

Page 80: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

{ "aps" : { "alert" : "You’re invited!", !

"category" : "INVITE_CATEGORY", !

} }

Page 81: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

{ "aps" : { "alert" : "You’re invited!", !

"category" : "INVITE_CATEGORY", !

} }

Page 82: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

{ "aps" : { "alert" : "You’re invited!", !

"category" : "INVITE_CATEGORY", !

} }

2KB Max Size

Page 83: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Local Notifications

UILocalNotification *notification = [[UILocalNotification alloc] init]; ... !

notification.category = @"INVITE_CATEGORY"; !

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

Page 84: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Local Notifications

UILocalNotification *notification = [[UILocalNotification alloc] init]; ... !

notification.category = @"INVITE_CATEGORY"; !

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

Page 85: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Local Notifications

UILocalNotification *notification = [[UILocalNotification alloc] init]; ... !

notification.category = @"INVITE_CATEGORY"; !

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

Page 86: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Local Notifications

UILocalNotification *notification = [[UILocalNotification alloc] init]; ... !

notification.category = @"INVITE_CATEGORY"; !

[[UIApplication sharedApplication] scheduleLocalNotification:notification];

Page 87: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Using Notification Actions

Register Actions

Push/Schedule Notification

Handle Action

Page 88: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Using Notification Actions

Register Actions

Push/Schedule Notification

Handle Action

Page 89: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification Actions

App

Page 90: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification Actions

App

UIApplicationDelegate

application:didFinishLaunchingWithOptions:

application:didReceiveRemoteNotification: fetchCompletionHandler:

Page 91: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification Actions

App

Page 92: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification Actions

App

UIApplicationDelegate

application:didReceiveLocalNotification:

application:didReceiveRemoteNotification: fetchCompletionHandler:

application:didReceiveRemoteNotification:

Page 93: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification Actions

App

Page 94: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification Actions

App

application:didFinishLaunchingWithOptions:

application:didReceiveRemoteNotification: fetchCompletionHandler:

UIApplicationDelegate

application:handleActionWithIdentifier: forRemoteNotification:completionHandler:

application:handleActionWithIdentifier: forLocalNotification:completionHandler:

Page 95: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification ActionsUIApplicationDelegate

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)notification completionHandler:(void (^)())completionHandler { if ([identifier isEqualToString:@"ACCEPT_IDENTIFIER"]) { [self handleAcceptActionWithNotification:notification]; } // Must be called when finished completionHandler(); }

Page 96: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification ActionsUIApplicationDelegate

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)notification completionHandler:(void (^)())completionHandler { if ([identifier isEqualToString:@"ACCEPT_IDENTIFIER"]) { [self handleAcceptActionWithNotification:notification]; } // Must be called when finished completionHandler(); }

Page 97: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification ActionsUIApplicationDelegate

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)notification completionHandler:(void (^)())completionHandler { if ([identifier isEqualToString:@"ACCEPT_IDENTIFIER"]) { [self handleAcceptActionWithNotification:notification]; } // Must be called when finished completionHandler(); }

Page 98: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification ActionsUIApplicationDelegate

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)notification completionHandler:(void (^)())completionHandler { if ([identifier isEqualToString:@"ACCEPT_IDENTIFIER"]) { [self handleAcceptActionWithNotification:notification]; } // Must be called when finished completionHandler(); }

Page 99: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification ActionsUIApplicationDelegate

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler { if ([identifier isEqualToString:@"ACCEPT_IDENTIFIER"]) { [self handleAcceptActionWithNotification:notification]; } // Must be called when finished completionHandler(); }

Page 100: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification ActionsUIApplicationDelegate

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler { if ([identifier isEqualToString:@"ACCEPT_IDENTIFIER"]) { [self handleAcceptActionWithNotification:notification]; } // Must be called when finished completionHandler(); }

Page 101: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification ActionsUIApplicationDelegate

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler { if ([identifier isEqualToString:@"ACCEPT_IDENTIFIER"]) { [self handleAcceptActionWithNotification:notification]; } // Must be called when finished completionHandler(); }

Page 102: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Handling Notification ActionsUIApplicationDelegate

- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler { if ([identifier isEqualToString:@"ACCEPT_IDENTIFIER"]) { [self handleAcceptActionWithNotification:notification]; } // Must be called when finished completionHandler(); }

Page 103: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Using Notification Actions

Register Actions

Push/Schedule Notification

Handle Action

Page 104: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Using Notification Actions

Register Actions

Push/Schedule Notification

Handle Action

UIUserNotificationAction

UIUserNotificationCategory

UIUserNotificationSettings

Page 105: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Using Notification Actions

Push/Schedule Notification

Handle Action

Register Actions

aps { alert: {…} category: "INVITE"

}

notification.category = @"INVITE";

Page 106: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

UIApplicationDelegate

Using Notification Actions

Push/Schedule Notification

Handle Action

Register Actions

application:handleActionWithIdentifier: forRemoteNotification:completionHandler:

application:handleActionWithIdentifier: forLocalNotification:completionHandler:

Page 107: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

Page 108: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

APNs

Page 109: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

APNs

My App Hello world!

aps { alert: {...}

}

Page 110: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

APNs

Page 111: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

APNsApp

Page 112: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

APNsApp

aps { content-available: 1

}

Page 113: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

APNsApp

aps { content-available: 1

}

Content Server

Page 114: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

Page 115: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

User • Requires call to registerUserNotificationSettings:

Silent • Info.plist UIBackgroundModes array contains remote-notification

Can use both

Page 116: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote Notifications

Must register before receiving pushes

Enabled by default

Can be disabled via Settings

Page 117: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsRegistering

UIApplication *myApp = [UIApplication sharedApplication]; !

!

[myApp registerForRemoteNotificationTypes:someTypes];

Page 118: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsRegistering

UIApplication *myApp = [UIApplication sharedApplication]; !

!

[myApp registerForRemoteNotificationTypes:someTypes]; !

!

Page 119: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsRegistering

UIApplication *myApp = [UIApplication sharedApplication]; !

!

[myApp registerForRemoteNotificationTypes:someTypes]; !

!

Page 120: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsRegistering

UIApplication *myApp = [UIApplication sharedApplication]; !

!

[myApp registerForRemoteNotificationTypes:someTypes]; !

!

[myApp registerForRemoteNotifications];

Page 121: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsRegistering

UIApplication *myApp = [UIApplication sharedApplication]; !

!

[myApp registerForRemoteNotificationTypes:someTypes]; !

!

[myApp registerForRemoteNotifications];

Page 122: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsRegistering

UIApplication *myApp = [UIApplication sharedApplication]; !

!

!

!

!

[myApp registerForRemoteNotifications]; !

[myApp registerUserNotificationSettings:mySettings];

Page 123: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsUIApplicationDelegate success callback

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { !

MyAPNSServer *myServer = // ... [myServer registerPushToken:deviceToken]; !

}

Page 124: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsUIApplicationDelegate success callback

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { !

MyAPNSServer *myServer = // ... [myServer registerPushToken:deviceToken]; !

}

Page 125: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsUIApplicationDelegate success callback

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { !

MyAPNSServer *myServer = // ... [myServer registerPushToken:deviceToken]; !

}

Page 126: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsUIApplicationDelegate failure callback

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { !

[self handleRegistrationError:error]; !

}

Page 127: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsUIApplicationDelegate failure callback

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { !

[self handleRegistrationError:error]; !

}

Page 128: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsUIApplicationDelegate failure callback

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { !

[self handleRegistrationError:error]; !

}

Page 129: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Remote NotificationsWrap up

Must register before using

Enabled by default

Register API change (registerForRemoteNotifications)

Page 130: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location Notifications

Page 131: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Subtitle

Page 132: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously
Page 133: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously
Page 134: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously
Page 135: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously
Page 136: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Uses UILocalNotification

Fire when user enters or exits a region

Fire-Once or Fire-Always

Requires Core Location registration

Location Notifications

Page 137: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsCore Location registration

CLLocationManager *locMan = [[CLLocationManager alloc] init]; !

locMan.delegate = self; !

// request authorization to track the user’s location [locMan requestWhenInUseAuthorization];

Page 138: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsCore Location registration

CLLocationManager *locMan = [[CLLocationManager alloc] init]; !

locMan.delegate = self; !

// request authorization to track the user’s location [locMan requestWhenInUseAuthorization];

Page 139: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsCore Location registration

CLLocationManager *locMan = [[CLLocationManager alloc] init]; !

locMan.delegate = self; !

// request authorization to track the user’s location [locMan requestWhenInUseAuthorization];

Page 140: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsCore Location registration

CLLocationManager *locMan = [[CLLocationManager alloc] init]; !

locMan.delegate = self; !

// request authorization to track the user’s location [locMan requestWhenInUseAuthorization];

Page 141: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsCore Location registration

CLLocationManager *locMan = [[CLLocationManager alloc] init]; !

locMan.delegate = self; !

// request authorization to track the user’s location [locMan requestWhenInUseAuthorization];

Page 142: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsCore Location registration

Key Type TypeInformation Property List

NSLocationWhenInUseUsageDescriptionLocalization native development regionBundle display nameExecutable file

DictionaryStringStringStringString

(17 items)

Enabling location tracking allows friends to see where you are.en${PRODUCT_NAME}${EXECUTABLE_NAME}

Page 143: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsCore Location registration

Key Type TypeInformation Property List

NSLocationWhenInUseUsageDescriptionLocalization native development regionBundle display nameExecutable file

DictionaryStringStringStringString

(17 items)

Enabling location tracking allows friends to see where you are.en${PRODUCT_NAME}${EXECUTABLE_NAME}

Page 144: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsCore Location registration callbacks

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { !

// check status to see if we’re authorized BOOL canUseLocationNotifications = (status == kCLAuthorizationStatusAuthorizedWhenInUse); !

if (canUseLocationNotifications) { [self startShowingLocationNotifications]; } !

}

Page 145: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsCore Location registration callbacks

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { !

// check status to see if we’re authorized BOOL canUseLocationNotifications = (status == kCLAuthorizationStatusAuthorizedWhenInUse); !

if (canUseLocationNotifications) { [self startShowingLocationNotifications]; } !

}

Page 146: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsCore Location registration callbacks

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { !

// check status to see if we’re authorized BOOL canUseLocationNotifications = (status == kCLAuthorizationStatusAuthorizedWhenInUse); !

if (canUseLocationNotifications) { [self startShowingLocationNotifications]; } !

}

Page 147: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsCore Location registration callbacks

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { !

// check status to see if we’re authorized BOOL canUseLocationNotifications = (status == kCLAuthorizationStatusAuthorizedWhenInUse); !

if (canUseLocationNotifications) { [self startShowingLocationNotifications]; } !

}

Page 148: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsNotification scheduling

- (void)startShowingNotifications { UILocalNotification *locNotification = [[UILocalNotification alloc] init]; locNotification.alertBody = @“You have arrived!”; locNotification.regionTriggersOnce = YES; !

locNotification.region = [[CLCircularRegion alloc] initWithCenter:LOC_COORDINATE radius:LOC_RADIUS identifier:LOC_IDENTIFIER]; !

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

Page 149: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsNotification scheduling

- (void)startShowingNotifications { UILocalNotification *locNotification = [[UILocalNotification alloc] init]; locNotification.alertBody = @“You have arrived!”; locNotification.regionTriggersOnce = YES; !

locNotification.region = [[CLCircularRegion alloc] initWithCenter:LOC_COORDINATE radius:LOC_RADIUS identifier:LOC_IDENTIFIER]; !

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

Page 150: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsNotification scheduling

- (void)startShowingNotifications { UILocalNotification *locNotification = [[UILocalNotification alloc] init]; locNotification.alertBody = @“You have arrived!”; locNotification.regionTriggersOnce = YES; !

locNotification.region = [[CLCircularRegion alloc] initWithCenter:LOC_COORDINATE radius:LOC_RADIUS identifier:LOC_IDENTIFIER]; !

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

Page 151: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsNotification scheduling

- (void)startShowingNotifications { UILocalNotification *locNotification = [[UILocalNotification alloc] init]; locNotification.alertBody = @“You have arrived!”; locNotification.regionTriggersOnce = YES; !

locNotification.region = [[CLCircularRegion alloc] initWithCenter:LOC_COORDINATE radius:LOC_RADIUS identifier:LOC_IDENTIFIER]; !

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

Page 152: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsNotification scheduling

- (void)startShowingNotifications { UILocalNotification *locNotification = [[UILocalNotification alloc] init]; locNotification.alertBody = @“You have arrived!”; locNotification.regionTriggersOnce = YES; !

locNotification.region = [[CLCircularRegion alloc] initWithCenter:LOC_COORDINATE radius:LOC_RADIUS identifier:LOC_IDENTIFIER]; !

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

Page 153: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsNotification handling

- (void)application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification { CLRegion *region = notification.region; !

if (region) { [self tellFriendsUserArrivedAtRegion:region]; } }

Page 154: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsNotification handling

- (void)application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification { CLRegion *region = notification.region; !

if (region) { [self tellFriendsUserArrivedAtRegion:region]; } }

Page 155: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsNotification handling

- (void)application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification { CLRegion *region = notification.region; !

if (region) { [self tellFriendsUserArrivedAtRegion:region]; } }

Page 156: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsNotification handling

- (void)application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification { CLRegion *region = notification.region; !

if (region) { [self tellFriendsUserArrivedAtRegion:region]; } }

Page 157: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Location NotificationsWrap up

UILocalNotification API addition

Requires Core Location registration

application:didReceiveLocalNotification: not called if CoreLocation disabled

Page 158: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Recap

Notification actions

User and Remote Notification registration

Location Notifications

Page 159: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

More Information

Paul Danbold Core OS Technologies Evangelist [email protected]

Documentation http://developer.apple.com

Apple Developer Forums http://devforums.apple.com

Page 160: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Related Sessions

• What’s New in Core Location Marina Tuesday 2:00PM

• Taking Core Location Indoors Marina Tuesday 3:15PM

• Protecting the User’s Data WWDC 2012

Page 161: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously

Labs

• Notifications Lab Services Lab B Wednesday 3:15PM

• Security and Privacy Lab Core OS Lab B Thursday 3:15PM

Page 162: What’s New in iOS Notifications - Apple Inc.€¦ · What’s New in iOS Notifications Core OS Session 713 Rhett Dickson Software Engineer! Dan Kurtz Software Engineer. Previously