Top Banner
#WWDC17 © 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Kritarth Jain, iOS Engineer Teja Kondapalli, iOS Engineer Best Practices and What’s New in User Notifications Session 708 System Frameworks
310

•Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Jul 18, 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: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

#WWDC17

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

Kritarth Jain, iOS Engineer Teja Kondapalli, iOS Engineer

•Best Practices and What’s New in User Notifications • Session 708

System Frameworks

Page 2: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

•Notifications overview •Hidden content •Modifying content •Customizing rich notifications •User input customization

Page 3: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

•Notifications Overview

Page 4: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Local Notifications

Page 5: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Local Notifications

Schedule

Page 6: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Remote Notifications

Page 7: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Remote Notifications

Remote Server

Page 8: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Remote Notifications

Notification Payload

Remote Server APNs

Page 9: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Remote Notifications

Notification Payload

Remote Server

Content

APNs

Page 10: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Remote Notifications

Notification Payload

Remote Server

Silent

Content

APNs

Page 11: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Content

Page 12: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Content

Page 13: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Content

Title

Page 14: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Content

TitleSubtitle

Page 15: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Content

TitleSubtitle

Body

Page 16: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Content

TitleSubtitle

Body Media Attachment

Page 17: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Triggers

Page 18: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Triggers

Push

Page 19: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Triggers

Push Calendar LocationTime Interval

Page 20: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Presentation

Page 21: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Presentation

Page 22: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Presentation

Page 23: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Presentation

Page 24: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Presentation

Page 25: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Presentation

Page 26: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Actions

Page 27: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Actions

Page 28: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Update

Page 29: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Update

Page 30: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Removal

Page 31: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Removal

Page 32: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Extensions Service Extension

Page 33: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Extensions Service Extension

Remote Server APNs

Page 34: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Extensions Service Extension

Remote Server

Service ExtensionAPNs

Page 35: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Extensions Content Extension

Page 36: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Extensions Content Extension

Page 37: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Extensions Content Extension

Page 38: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Notification Extensions Content Extension

Page 39: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

watchOS Notifications

Page 40: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

watchOS Notifications

Page 41: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 42: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

UserNotifications UserNotificationsUI

Page 43: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

WWDC 2016 Sessions

Introduction to User Notifications WWDC 2016

Advanced User Notifications WWDC 2016

Page 44: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Teja Kondapalli, iOS Engineer

•Hidden Notification Content

Page 45: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Teja Kondapalli, iOS Engineer

•Hidden Notification Content

NEW

Page 46: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 47: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Privacy

Page 48: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 49: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 50: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 51: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 52: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Not Authenticated

Page 53: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 54: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 55: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content What’s new

Page 56: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content What’s new

NEW

Page 57: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content What’s new

Extended support to all apps

NEW

Page 58: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content What’s new

Extended support to all apps

Global setting

NEW

Page 59: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

NEW

Page 60: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

NEW

Page 61: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content What’s new

Extended support to all apps

Global setting

NEW

Page 62: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content What’s new

Extended support to all apps

Global setting

Settings per app

NEW

Page 63: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

NEW

Page 64: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

NEW

Page 65: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content What’s new

Extended support to all apps

Global setting

Settings per app

NEW

Page 66: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content What’s new

Extended support to all apps

Global setting

Settings per app

API to customize notification content

NEW

Page 67: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 68: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

NEW

Page 69: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Body Placeholder

NEW

Page 70: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 71: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 72: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

NEW

Page 73: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

NEW

Page 74: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 75: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 76: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: "Comment")

NEW

Page 77: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: "Comment")

NEW

Page 78: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: "Comment")

NEW

Page 79: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 80: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder:"%u Comments")

NEW

Page 81: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 82: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 83: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content Pluralization

Page 84: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content Pluralization

Page 85: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content Pluralization

Page 86: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content Pluralization

Page 87: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content Pluralization

Page 88: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: NSString.localizedUserNotificationString(forKey:”COMMENT_KEY”, arguments: nil))

NEW

Page 89: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: NSString.localizedUserNotificationString(forKey:”COMMENT_KEY”, arguments: nil))

NEW

Page 90: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: NSString.localizedUserNotificationString(forKey:”COMMENT_KEY”, arguments: nil))

Localizing with [Xcode9] WWDC 2017

NEW

Page 91: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 92: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 93: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: NSString.localizedUserNotificationString(forKey:”COMMENT_KEY”, arguments: nil))

let imageCategory = UNNotificationCategory(identifier: "image-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: NSString.localizedUserNotificationString(forKey:”IMAGE_KEY", arguments: nil))

Page 94: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: NSString.localizedUserNotificationString(forKey:”COMMENT_KEY”, arguments: nil))

let imageCategory = UNNotificationCategory(identifier: "image-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: NSString.localizedUserNotificationString(forKey:”IMAGE_KEY", arguments: nil))

Page 95: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: NSString.localizedUserNotificationString(forKey:”COMMENT_KEY”, arguments: nil))

let imageCategory = UNNotificationCategory(identifier: "image-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: NSString.localizedUserNotificationString(forKey:”IMAGE_KEY", arguments: nil))

Page 96: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 97: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 98: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: NSString.localizedUserNotificationString(forKey:”COMMENT_KEY”, arguments: nil), options: [.hiddenPreviewsShowTitle])

NEW

Page 99: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Hidden Notification Content

let commentCategory = UNNotificationCategory(identifier: "comment-category", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: NSString.localizedUserNotificationString(forKey:”COMMENT_KEY”, arguments: nil), options: [.hiddenPreviewsShowTitle])

NEW

Page 100: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 101: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content Best practices

Page 102: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Hidden Notification Content Best practices

Page 103: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User defined setting

Hidden Notification Content Best practices

Page 104: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User defined setting

Retrieve settings using showPreviewsSetting

Hidden Notification Content Best practices

Page 105: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User defined setting

Retrieve settings using showPreviewsSetting

Thread identifiers

Hidden Notification Content Best practices

Page 106: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User defined setting

Retrieve settings using showPreviewsSetting

Thread identifiers

Pluralization

Hidden Notification Content Best practices

Page 107: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

•Attachments, Encryption, and More •Modifying push content

Page 108: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Use cases

Page 109: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Download media attachments

Modifying Push Content Use cases

Page 110: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Download media attachments

Content encryption

Modifying Push Content Use cases

Page 111: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Download media attachments

Content encryption

Context specific content—location, time, health data

Modifying Push Content Use cases

Page 112: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 113: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Service Extension

Page 114: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Example

Page 115: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Example

Remote Server

Page 116: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Example

Remote Server APNs

Page 117: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Example

Remote Server

Service Extension

APNs

Page 118: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Example

Remote Server

Service Extension

APNs

Page 119: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Example

Remote Server

Service Extension

Download video preview

APNs

Page 120: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Example

Remote Server

Service Extension

Download video preview

APNs

Page 121: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

{ "aps": { "alert": { … }, "mutable-content": 1 }, "type": "video", "video-url": "https://www.example.com/media/myvideo.m4a", "video-location": "Skate Park, SF", "video-user": "John Appleseed" }

Page 122: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

{ "aps": { "alert": { … }, "mutable-content": 1 }, "type": "video", "video-url": "https://www.example.com/media/myvideo.m4a", "video-location": "Skate Park, SF", "video-user": "John Appleseed" }

Page 123: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

{ "aps": { "alert": { … }, "mutable-content": 1 }, "type": "video", "video-url": "https://www.example.com/media/myvideo.m4a", "video-location": "Skate Park, SF", "video-user": "John Appleseed" }

Page 124: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Service Extension Template

Page 125: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) {

self.contentHandler = contentHandler self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

… // Handle request before presenting } }

Page 126: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) {

self.contentHandler = contentHandler self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

… // Handle request before presenting } }

Page 127: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) {

self.contentHandler = contentHandler self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

… // Handle request before presenting } }

Page 128: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) {

self.contentHandler = contentHandler self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

… // Handle request before presenting } }

Page 129: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) {

self.contentHandler = contentHandler self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

… // Handle request before presenting } }

Page 130: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) {

self.contentHandler = contentHandler self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

… // Handle request before presenting } }

Page 131: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) { … if let mutableContent = self.bestAttemptContent, let urlString = mutableContent.userInfo["video-url"] as? String {

self.download(url: urlString) { (fileLocation) in if let attachment = try? UNNotificationAttachment(identifier: "video", url: fileLocation) { mutableContent.attachments = [ attachment ] contentHandler(mutableContent) } } } }

Page 132: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) { … if let mutableContent = self.bestAttemptContent, let urlString = mutableContent.userInfo["video-url"] as? String {

self.download(url: urlString) { (fileLocation) in if let attachment = try? UNNotificationAttachment(identifier: "video", url: fileLocation) { mutableContent.attachments = [ attachment ] contentHandler(mutableContent) } } } }

Page 133: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) { … if let mutableContent = self.bestAttemptContent, let urlString = mutableContent.userInfo["video-url"] as? String {

self.download(url: urlString) { (fileLocation) in if let attachment = try? UNNotificationAttachment(identifier: "video", url: fileLocation) { mutableContent.attachments = [ attachment ] contentHandler(mutableContent) } } } }

Page 134: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) { … if let mutableContent = self.bestAttemptContent, let urlString = mutableContent.userInfo["video-url"] as? String {

self.download(url: urlString) { (fileLocation) in if let attachment = try? UNNotificationAttachment(identifier: "video", url: fileLocation) { mutableContent.attachments = [ attachment ] contentHandler(mutableContent) } } } }

Page 135: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) { … if let mutableContent = self.bestAttemptContent, let urlString = mutableContent.userInfo["video-url"] as? String {

self.download(url: urlString) { (fileLocation) in if let attachment = try? UNNotificationAttachment(identifier: "video", url: fileLocation) { mutableContent.attachments = [ attachment ] contentHandler(mutableContent) } } } }

Page 136: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

override public func didReceive(_ request: UNNotificationRequest, @escaping withContentHandler contentHandler: (UNNotificationContent) -> Void) { … if let mutableContent = self.bestAttemptContent, let urlString = mutableContent.userInfo["video-url"] as? String {

self.download(url: urlString) { (fileLocation) in if let attachment = try? UNNotificationAttachment(identifier: "video", url: fileLocation) { mutableContent.attachments = [ attachment ] contentHandler(mutableContent) } } } }

Page 137: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 138: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override func serviceExtensionTimeWillExpire() { if let contentHandler = self.contentHandler, let bestAttemptContent = self.bestAttemptContent, let mediaType = bestAttemptContent.userInfo["type"] as? String { bestAttemptContent.title = "Incoming \(mediaType)!",

contentHandler(bestAttemptContent) } } }

Page 139: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override func serviceExtensionTimeWillExpire() { if let contentHandler = self.contentHandler, let bestAttemptContent = self.bestAttemptContent, let mediaType = bestAttemptContent.userInfo["type"] as? String { bestAttemptContent.title = "Incoming \(mediaType)!",

contentHandler(bestAttemptContent) } } }

Page 140: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override func serviceExtensionTimeWillExpire() { if let contentHandler = self.contentHandler, let bestAttemptContent = self.bestAttemptContent, let mediaType = bestAttemptContent.userInfo["type"] as? String { bestAttemptContent.title = "Incoming \(mediaType)!",

contentHandler(bestAttemptContent) } } }

Page 141: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override func serviceExtensionTimeWillExpire() { if let contentHandler = self.contentHandler, let bestAttemptContent = self.bestAttemptContent, let mediaType = bestAttemptContent.userInfo["type"] as? String { bestAttemptContent.title = "Incoming \(mediaType)!",

contentHandler(bestAttemptContent) } } }

Page 142: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override func serviceExtensionTimeWillExpire() { if let contentHandler = self.contentHandler, let bestAttemptContent = self.bestAttemptContent, let mediaType = bestAttemptContent.userInfo["type"] as? String { bestAttemptContent.title = "Incoming \(mediaType)!",

contentHandler(bestAttemptContent) } } }

Page 143: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Modifying Push Content

public class NotificationService: UNNotificationServiceExtension { var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?

override func serviceExtensionTimeWillExpire() { if let contentHandler = self.contentHandler, let bestAttemptContent = self.bestAttemptContent, let mediaType = bestAttemptContent.userInfo["type"] as? String { bestAttemptContent.title = "Incoming \(mediaType)!",

contentHandler(bestAttemptContent) } } }

Page 144: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Service Extension best practices

Page 145: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Service Extension best practices

Page 146: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Service Extension best practices

Short execution time and memory limit

Page 147: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Service Extension best practices

Short execution time and memory limit

Fallback

Page 148: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Service Extension best practices

Short execution time and memory limit

Fallback

Notifications will be presented

Page 149: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Service Extension best practices

Short execution time and memory limit

Fallback

Notifications will be presented

Different from silent notifications

Page 150: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Service Extension best practices

APNs

Page 151: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Modifying Push Content Service Extension best practices

APNs

Page 152: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Service Extension

Modifying Push Content Service Extension best practices

APNs

Page 153: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Service Extension

Modifying Push Content Service Extension best practices

APNs

Page 154: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Service Extension

Modifying Push Content Service Extension best practices

APNs

Page 155: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Silent Notification

Service Extension

Modifying Push Content Service Extension best practices

APNs

Page 156: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 157: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 158: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

•Customizing Rich Notifications

Page 159: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 160: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Motivation

Page 161: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

App specific look and feel

Customizing Rich Notifications Motivation

Page 162: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

App specific look and feel

Custom display of notification content

Customizing Rich Notifications Motivation

Page 163: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

App specific look and feel

Custom display of notification content

Interactive and dynamic UI

Customizing Rich Notifications Motivation

Page 164: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 165: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Content Extensions

Page 166: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension

Service Extension

Page 167: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension

Service Extension

Content Extension

Launch

Page 168: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension

Service Extension

Content Extension

LaunchView

Controller

Page 169: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 170: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customize Title

Page 171: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customize Title

Customize UI

Page 172: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customize Title

Customize UI

Remove Default Content

Page 173: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension Template

Page 174: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension Template

Page 175: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension Info.plist

Page 176: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension Info.plist

Page 177: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension Info.plist

Page 178: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension Info.plist

Page 179: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension Info.plist

Page 180: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var videoPlayer: AVPlayer?

func didReceive(_ notification: UNNotification) { let content = notification.request.content if let attachment = content.attachments.first { if attachment.url.startAccessingSecurityScopedResource() { videoPlayer = AVPlayer(url: attachment.url) attachment.url.stopAccessingSecurityScopedResource() } } } }

Page 181: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var videoPlayer: AVPlayer?

func didReceive(_ notification: UNNotification) { let content = notification.request.content if let attachment = content.attachments.first { if attachment.url.startAccessingSecurityScopedResource() { videoPlayer = AVPlayer(url: attachment.url) attachment.url.stopAccessingSecurityScopedResource() } } } }

Page 182: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var videoPlayer: AVPlayer?

func didReceive(_ notification: UNNotification) { let content = notification.request.content if let attachment = content.attachments.first { if attachment.url.startAccessingSecurityScopedResource() { videoPlayer = AVPlayer(url: attachment.url) attachment.url.stopAccessingSecurityScopedResource() } } } }

Page 183: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var videoPlayer: AVPlayer?

func didReceive(_ notification: UNNotification) { let content = notification.request.content if let attachment = content.attachments.first { if attachment.url.startAccessingSecurityScopedResource() { videoPlayer = AVPlayer(url: attachment.url) attachment.url.stopAccessingSecurityScopedResource() } } } }

Page 184: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var videoPlayer: AVPlayer?

func didReceive(_ notification: UNNotification) { let content = notification.request.content if let attachment = content.attachments.first { if attachment.url.startAccessingSecurityScopedResource() { videoPlayer = AVPlayer(url: attachment.url) attachment.url.stopAccessingSecurityScopedResource() } } } }

Page 185: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var videoPlayer: AVPlayer?

func didReceive(_ notification: UNNotification) { let content = notification.request.content if let attachment = content.attachments.first { if attachment.url.startAccessingSecurityScopedResource() { videoPlayer = AVPlayer(url: attachment.url) attachment.url.stopAccessingSecurityScopedResource() } } } }

Page 186: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension { @IBOutlet var userLabel: UILabel? @IBOutlet var locationLabel: UILabel? @IBOutlet var descriptionLabel: UILabel?

func didReceive(_ notification: UNNotification) { let content = notification.request.content self.title = content.title

let userInfo = content.userInfo self.userLabel?.text = userInfo["video-user"] as? String self.locationLabel?.text = userInfo["video-location"] as? String self.descriptionLabel?.text = userInfo["video-description"] as? String } }

Page 187: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension { @IBOutlet var userLabel: UILabel? @IBOutlet var locationLabel: UILabel? @IBOutlet var descriptionLabel: UILabel?

func didReceive(_ notification: UNNotification) { let content = notification.request.content self.title = content.title

let userInfo = content.userInfo self.userLabel?.text = userInfo["video-user"] as? String self.locationLabel?.text = userInfo["video-location"] as? String self.descriptionLabel?.text = userInfo["video-description"] as? String } }

Page 188: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension { @IBOutlet var userLabel: UILabel? @IBOutlet var locationLabel: UILabel? @IBOutlet var descriptionLabel: UILabel?

func didReceive(_ notification: UNNotification) { let content = notification.request.content self.title = content.title

let userInfo = content.userInfo self.userLabel?.text = userInfo["video-user"] as? String self.locationLabel?.text = userInfo["video-location"] as? String self.descriptionLabel?.text = userInfo["video-description"] as? String } }

Page 189: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension { @IBOutlet var userLabel: UILabel? @IBOutlet var locationLabel: UILabel? @IBOutlet var descriptionLabel: UILabel?

func didReceive(_ notification: UNNotification) { let content = notification.request.content self.title = content.title

let userInfo = content.userInfo self.userLabel?.text = userInfo["video-user"] as? String self.locationLabel?.text = userInfo["video-location"] as? String self.descriptionLabel?.text = userInfo["video-description"] as? String } }

Page 190: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension { @IBOutlet var userLabel: UILabel? @IBOutlet var locationLabel: UILabel? @IBOutlet var descriptionLabel: UILabel?

func didReceive(_ notification: UNNotification) { let content = notification.request.content self.title = content.title

let userInfo = content.userInfo self.userLabel?.text = userInfo["video-user"] as? String self.locationLabel?.text = userInfo["video-location"] as? String self.descriptionLabel?.text = userInfo["video-description"] as? String } }

Page 191: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// Content Extension Custom UI

class NotificationViewController: UIViewController, UNNotificationContentExtension { @IBOutlet var userLabel: UILabel? @IBOutlet var locationLabel: UILabel? @IBOutlet var descriptionLabel: UILabel?

func didReceive(_ notification: UNNotification) { let content = notification.request.content self.title = content.title

let userInfo = content.userInfo self.userLabel?.text = userInfo["video-user"] as? String self.locationLabel?.text = userInfo["video-location"] as? String self.descriptionLabel?.text = userInfo["video-description"] as? String } }

Page 192: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 193: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 194: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 195: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 196: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Custom Title

Page 197: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Custom Title

Custom UI

Page 198: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Custom Title

Custom UI

No Default Content

Page 199: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 200: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 201: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension size ratio

Page 202: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension size ratio

Page 203: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customizing Rich Notifications Content Extension size ratio

Page 204: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 205: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 206: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customize Rich Notifications Best practices

Page 207: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Customize Rich Notifications Best practices

Page 208: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Custom UI elements

Customize Rich Notifications Best practices

Page 209: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Custom UI elements

Display all relevant information

Customize Rich Notifications Best practices

Page 210: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Custom UI elements

Display all relevant information

Reuse app view controllers

Customize Rich Notifications Best practices

Page 211: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Custom UI elements

Display all relevant information

Reuse app view controllers

Correct sizing

Customize Rich Notifications Best practices

Page 212: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Custom UI elements

Display all relevant information

Reuse app view controllers

Correct sizing

Fast loading and layout

Customize Rich Notifications Best practices

Page 213: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 214: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

•User Input Customization

Page 215: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 216: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

No Touches

Page 217: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User Input Customization

Page 218: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Media buttons

User Input Customization

Page 219: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Media buttons

Actions

User Input Customization

Page 220: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Media buttons

Actions

Custom input views

User Input Customization

Page 221: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 222: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Play Button

Page 223: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Media Controls class NotificationViewController: UIViewController, UNNotificationContentExtension {

var mediaPlayPauseButtonFrame: CGRect { return CGRect(x: buttonX, y: buttonY, width: buttonWidth, height: buttonHeight) }

var mediaPlayPauseButtonTintColor: UIColor { return .white }

var mediaPlayPauseButtonType: UNNotificationContentExtensionMediaPlayPauseButtonType { return .default } }

Page 224: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Media Controls class NotificationViewController: UIViewController, UNNotificationContentExtension {

var mediaPlayPauseButtonFrame: CGRect { return CGRect(x: buttonX, y: buttonY, width: buttonWidth, height: buttonHeight) }

var mediaPlayPauseButtonTintColor: UIColor { return .white }

var mediaPlayPauseButtonType: UNNotificationContentExtensionMediaPlayPauseButtonType { return .default } }

Page 225: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Media Controls class NotificationViewController: UIViewController, UNNotificationContentExtension {

var mediaPlayPauseButtonFrame: CGRect { return CGRect(x: buttonX, y: buttonY, width: buttonWidth, height: buttonHeight) }

var mediaPlayPauseButtonTintColor: UIColor { return .white }

var mediaPlayPauseButtonType: UNNotificationContentExtensionMediaPlayPauseButtonType { return .default } }

Page 226: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Media Controls class NotificationViewController: UIViewController, UNNotificationContentExtension {

var mediaPlayPauseButtonFrame: CGRect { return CGRect(x: buttonX, y: buttonY, width: buttonWidth, height: buttonHeight) }

var mediaPlayPauseButtonTintColor: UIColor { return .white }

var mediaPlayPauseButtonType: UNNotificationContentExtensionMediaPlayPauseButtonType { return .default } }

Page 227: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Media Controls class NotificationViewController: UIViewController, UNNotificationContentExtension {

var mediaPlayPauseButtonFrame: CGRect { return CGRect(x: buttonX, y: buttonY, width: buttonWidth, height: buttonHeight) }

var mediaPlayPauseButtonTintColor: UIColor { return .white }

var mediaPlayPauseButtonType: UNNotificationContentExtensionMediaPlayPauseButtonType { return .default } }

Page 228: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Media Controls class NotificationViewController: UIViewController, UNNotificationContentExtension {

var mediaPlayPauseButtonFrame: CGRect { return CGRect(x: buttonX, y: buttonY, width: buttonWidth, height: buttonHeight) }

var mediaPlayPauseButtonTintColor: UIColor { return .white }

var mediaPlayPauseButtonType: UNNotificationContentExtensionMediaPlayPauseButtonType { return .default } }

Page 229: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Media Controls class NotificationViewController: UIViewController, UNNotificationContentExtension {

func mediaPlay() { self.videoPlayer?.play() } func mediaPause() { self.videoPlayer?.pause() }

}

Page 230: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Media Controls class NotificationViewController: UIViewController, UNNotificationContentExtension {

func mediaPlay() { self.videoPlayer?.play() } func mediaPause() { self.videoPlayer?.pause() }

}

Page 231: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Media Controls class NotificationViewController: UIViewController, UNNotificationContentExtension {

func mediaPlay() { self.videoPlayer?.play() } func mediaPause() { self.videoPlayer?.pause() }

}

Page 232: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Media Controls class NotificationViewController: UIViewController, UNNotificationContentExtension {

func mediaPlay() { self.videoPlayer?.play() } func mediaPause() { self.videoPlayer?.pause() }

}

Page 233: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 234: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 235: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 236: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 237: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User Input Customization Action handling

Page 238: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User Input Customization Action handling

Handle Action

Page 239: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User Input Customization Action handling

Content Extension

Handle Action

Page 240: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User Input Customization Action handling

Content Extension

Handle Action

Intercept Action

Page 241: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User Input Customization Action handling

Content Extension

Handle Action

Intercept Action

Forward Action

Page 242: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

let likeAction = UNNotificationAction(identifier: "like-action", title: "Like") let commentAction = UNTextInputNotificationAction(identifier: "comment-action", title: "Comment", textInputButtonTitle: "Post", textInputPlaceholder: "Comment")

let category = UNNotificationCategory(identifier: "video-playback-category", actions: [ likeAction, commentAction ], intentIdentifiers: [])

Page 243: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

let likeAction = UNNotificationAction(identifier: "like-action", title: "Like") let commentAction = UNTextInputNotificationAction(identifier: "comment-action", title: "Comment", textInputButtonTitle: "Post", textInputPlaceholder: "Comment")

let category = UNNotificationCategory(identifier: "video-playback-category", actions: [ likeAction, commentAction ], intentIdentifiers: [])

Page 244: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

let likeAction = UNNotificationAction(identifier: "like-action", title: "Like") let commentAction = UNTextInputNotificationAction(identifier: "comment-action", title: "Comment", textInputButtonTitle: "Post", textInputPlaceholder: "Comment")

let category = UNNotificationCategory(identifier: "video-playback-category", actions: [ likeAction, commentAction ], intentIdentifiers: [])

Page 245: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

let likeAction = UNNotificationAction(identifier: "like-action", title: "Like") let commentAction = UNTextInputNotificationAction(identifier: "comment-action", title: "Comment", textInputButtonTitle: "Post", textInputPlaceholder: "Comment")

let category = UNNotificationCategory(identifier: "video-playback-category", actions: [ likeAction, commentAction ], intentIdentifiers: [])

Page 246: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

let likeAction = UNNotificationAction(identifier: "like-action", title: "Like") let commentAction = UNTextInputNotificationAction(identifier: "comment-action", title: "Comment", textInputButtonTitle: "Post", textInputPlaceholder: "Comment")

let category = UNNotificationCategory(identifier: "video-playback-category", actions: [ likeAction, commentAction ], intentIdentifiers: [])

Page 247: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var likeLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "like-action" { self.likeLabel?.text = "👍" }

completionHandler(.doNotDismiss) }

}

Page 248: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var likeLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "like-action" { self.likeLabel?.text = "👍" }

completionHandler(.doNotDismiss) }

}

Page 249: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var likeLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "like-action" { self.likeLabel?.text = "👍" }

completionHandler(.doNotDismiss) }

}

Page 250: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var likeLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "like-action" { self.likeLabel?.text = "👍" }

completionHandler(.doNotDismiss) }

}

Page 251: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var likeLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "like-action" { self.likeLabel?.text = "👍" }

completionHandler(.doNotDismiss) }

}

Page 252: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var likeLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "like-action" { self.likeLabel?.text = "👍" }

completionHandler(.doNotDismiss) }

}

Page 253: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var likeLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "like-action" { self.likeLabel?.text = "👍" }

completionHandler(.doNotDismiss) }

}

Page 254: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 255: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 256: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var commentLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "comment-action" { if let textResponse = response as? UNTextInputNotificationResponse { self.commentLabel?.text = textResponse.userText } } completionHandler(.doNotDismiss) } }

Page 257: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var commentLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "comment-action" { if let textResponse = response as? UNTextInputNotificationResponse { self.commentLabel?.text = textResponse.userText } } completionHandler(.doNotDismiss) } }

Page 258: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var commentLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "comment-action" { if let textResponse = response as? UNTextInputNotificationResponse { self.commentLabel?.text = textResponse.userText } } completionHandler(.doNotDismiss) } }

Page 259: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var commentLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "comment-action" { if let textResponse = response as? UNTextInputNotificationResponse { self.commentLabel?.text = textResponse.userText } } completionHandler(.doNotDismiss) } }

Page 260: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var commentLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "comment-action" { if let textResponse = response as? UNTextInputNotificationResponse { self.commentLabel?.text = textResponse.userText } } completionHandler(.doNotDismiss) } }

Page 261: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var commentLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "comment-action" { if let textResponse = response as? UNTextInputNotificationResponse { self.commentLabel?.text = textResponse.userText } } completionHandler(.doNotDismiss) } }

Page 262: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Action Handling

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var commentLabel: UILabel?

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { server.postEventResponse(response) if response.actionIdentifier == "comment-action" { if let textResponse = response as? UNTextInputNotificationResponse { self.commentLabel?.text = textResponse.userText } } completionHandler(.doNotDismiss) } }

Page 263: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 264: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 265: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 266: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 267: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 268: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Custom User Input

Page 269: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 270: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 271: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

UIResponder

Page 272: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Custom Input View

let reactionsAction = UNNotificationAction(identifier: "reactions-action", title: "Reaction")

let category = UNNotificationCategory(identifier: "video-playback-category", actions: [ reactionsAction ], intentIdentifiers: [])

Page 273: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Custom Input View

let reactionsAction = UNNotificationAction(identifier: "reactions-action", title: "Reaction")

let category = UNNotificationCategory(identifier: "video-playback-category", actions: [ reactionsAction ], intentIdentifiers: [])

Page 274: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Custom Input View

let reactionsAction = UNNotificationAction(identifier: "reactions-action", title: "Reaction")

let category = UNNotificationCategory(identifier: "video-playback-category", actions: [ reactionsAction ], intentIdentifiers: [])

Page 275: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Custom Input View

let reactionsAction = UNNotificationAction(identifier: "reactions-action", title: "Reaction")

let category = UNNotificationCategory(identifier: "video-playback-category", actions: [ reactionsAction ], intentIdentifiers: [])

Page 276: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Custom Input View

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var customInputView: UIView

override public var canBecomeFirstResponder : Bool { return true }

override var inputView: UIView { return self.customInputView }

}

Page 277: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Custom Input View

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var customInputView: UIView

override public var canBecomeFirstResponder : Bool { return true }

override var inputView: UIView { return self.customInputView }

}

Page 278: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Custom Input View

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var customInputView: UIView

override public var canBecomeFirstResponder : Bool { return true }

override var inputView: UIView { return self.customInputView }

}

Page 279: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization - Custom Input View

class NotificationViewController: UIViewController, UNNotificationContentExtension {

var customInputView: UIView

override public var canBecomeFirstResponder : Bool { return true }

override var inputView: UIView { return self.customInputView }

}

Page 280: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization — Custom Input View

class NotificationViewController: UIViewController, UNNotificationContentExtension {

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { if response.actionIdentifier == "reactions-action" { self.becomeFirstResponder() } }

func handleReactionButtonPress(sender: UIButton) { self.reactionLabel?.text = sender.currentTitle self.resignFirstResponder() } }

Page 281: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization — Custom Input View

class NotificationViewController: UIViewController, UNNotificationContentExtension {

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { if response.actionIdentifier == "reactions-action" { self.becomeFirstResponder() } }

func handleReactionButtonPress(sender: UIButton) { self.reactionLabel?.text = sender.currentTitle self.resignFirstResponder() } }

Page 282: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization — Custom Input View

class NotificationViewController: UIViewController, UNNotificationContentExtension {

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { if response.actionIdentifier == "reactions-action" { self.becomeFirstResponder() } }

func handleReactionButtonPress(sender: UIButton) { self.reactionLabel?.text = sender.currentTitle self.resignFirstResponder() } }

Page 283: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization — Custom Input View

class NotificationViewController: UIViewController, UNNotificationContentExtension {

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { if response.actionIdentifier == "reactions-action" { self.becomeFirstResponder() } }

func handleReactionButtonPress(sender: UIButton) { self.reactionLabel?.text = sender.currentTitle self.resignFirstResponder() } }

Page 284: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization — Custom Input View

class NotificationViewController: UIViewController, UNNotificationContentExtension {

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { if response.actionIdentifier == "reactions-action" { self.becomeFirstResponder() } }

func handleReactionButtonPress(sender: UIButton) { self.reactionLabel?.text = sender.currentTitle self.resignFirstResponder() } }

Page 285: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization — Custom Input View

class NotificationViewController: UIViewController, UNNotificationContentExtension {

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { if response.actionIdentifier == "reactions-action" { self.becomeFirstResponder() } }

func handleReactionButtonPress(sender: UIButton) { self.reactionLabel?.text = sender.currentTitle self.resignFirstResponder() } }

Page 286: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

// User Input Customization — Custom Input View

class NotificationViewController: UIViewController, UNNotificationContentExtension {

func didReceive(_ response: UNNotificationResponse, completionHandler completion: (UNNotificationContentExtensionResponseOption) -> Void) { if response.actionIdentifier == "reactions-action" { self.becomeFirstResponder() } }

func handleReactionButtonPress(sender: UIButton) { self.reactionLabel?.text = sender.currentTitle self.resignFirstResponder() } }

Page 287: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 288: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 289: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 290: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 291: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User Input Customization Best practices

Page 292: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

User Input Customization Best practices

Page 293: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Media buttons

User Input Customization Best practices

Page 294: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Media buttons

Context specific actions

User Input Customization Best practices

Page 295: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Media buttons

Context specific actions

To dismiss or not to dismiss

User Input Customization Best practices

Page 296: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Media buttons

Context specific actions

To dismiss or not to dismiss

Custom user input view gives you full control

User Input Customization Best practices

Page 297: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

•Showcase Apps

Page 298: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 299: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 300: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 301: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension
Page 302: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Summary

Page 303: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Summary

Overview

Page 304: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Summary

Overview

Hidden notification content

Page 305: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Summary

Overview

Hidden notification content

Modifying content

Page 306: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Summary

Overview

Hidden notification content

Modifying content

Customizing rich notifications

Page 307: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Summary

Overview

Hidden notification content

Modifying content

Customizing rich notifications

User input customization

Page 308: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

More Informationhttps://developer.apple.com/wwdc17/708

Page 309: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension

Labs

Notifications Lab Technology Lab J Thursday 1:50PM–4:00PM

Page 310: •Best Practices and What’s New in User Notifications · 2017-09-26 · •Best Practices and What’s New in User Notifications • ... Modifying Push Content Service Extension