SlideShare a Scribd company logo
Notification Framework
DMI Internal Tech Talk
Sokna Ly
Associate Software Engineer, iOS
Agenda
Notifications Overview
User Notifications Framework
• Registration
• Content
• Trigger
• Management
• Actions
Agenda
Service Extensions
Media Attachments
Notifications User Interface
Overview
Existing API Overview
• Different callbacks for local and remote notifications
Limited control after notifications are scheduled
• Different support across multiple platforms
• Depreciated in iOS 10
User Notifications Framework
• Familiar API
• Expanded content
• Same code path for local and remote notification handling S
• Better notification management
• In-app presentation option
• Schedule and handle notifications in extensions
User Notifications Framework
Registration
User Authorization Options
• Badging
• Sound Alerts
• Banners
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in
// Code for handling goes here
}
Needed for both local and remote notifications
User Notifications Framework
Content
Title
Subtitle
Body
Media Attachment
User Notifications Framework
let content = UNMutableNotificationContent()
content.title = “This is title"
content.subtitle = “This is subtitle"
content.body = “I’m body…wahooo!”
content.badge = 1
Local Notification
Remote Notification
{
"aps": {
"alert": {
"title": "This is title",
"subtitle": "This is subtitle",
"body": "I'm body...wahooo!"
},
"badge": 1
}
}
User Notifications Framework
Trigger
Time Interval CalendarLocation Push
Trigger
Time Interval
Example
UNTimeIntervalNotificationTrigger(timeInterval: 60,
repeats: false)
• “In 1 minute from now”
• “Repeat every hour starting now”
UNTimeIntervalNotificationTrigger(timeInterval: 3600,
repeats: false)
Trigger
Calendar
Example
let dateComponents = DateComponents()
// Configure dateComponents
UNCalendarNotificationTrigger(dateMatching: dateComponents,
repeats: false)
• “2:00pm tomorrow for meeting”
• “Repeat every Weekdays at 6:00am for gym”
Trigger
Calendar
Example
let region = CLRegion()
// Configure region
UNLocationNotificationTrigger(region: region,
repeats: false)
• “When leaving home”
• “When arriving in proximity of shopping store”
User Notifications Framework
Management
Add notification request
Update and promote Notifications
Remove Notifications (Pending, Delivered)
User Notifications Framework
Actions
Buttons with customizable title
Background and foreground
Text input
iOS and watchOS
Actions
Registration
let replyAction = UNTextInputNotificationAction(identifier: "reply",
title: "Reply",
options: [],
textInputButtonTitle: "Send",
textInputPlaceholder: "Type message here...")
let seenAction = UNNotificationAction(identifier:"seen",
title:"Mark as Read",
options:[])
let dismissAction = UNNotificationAction(identifier:"dismiss",
title:"Dismiss",
options:[])
let category = UNNotificationCategory(identifier: "chat-event",
actions: [replyAction, seenAction, dismissAction],
minimalActions: [replyAction,dismissAction],
intentIdentifiers: [], options: [])
UNUserNotificationCenter.current().setNotificationCategories([category])
Actions
Presentation
Local Notification
Remote Notification
let content = UNMutableNotificationContent()
content.categoryIdentifier = "chat-event"
{
"aps": {
"alert": "Someone chat to you.",
"category":"chat-event"
}
}
Service Extension
Basic
• Non UI iOS Extension
• Augment or Replace of content of
Remote Notifications
• End-to-end encryption
• Short execution time
• Add attachments
Service Extension
Old school
Server-side App APNs Device
New school
Server-side App APNs DeviceExtension
Service Extension
Implementation
It’s time for implementation
Media Attachments
Basic
• Local and remote notifications
• Support image, audio, video, gif
• Download in the service extension
• Limited processing time and size
Media Attachment
Implementation
override func didReceive(_ request: UNNotificationRequest,
withContentHandler contentHandler:(UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
let content = (request.content.mutableCopy() as! UNMutableNotificationContent)
// Handle attachment downloading
let url = // file url
let attachment = try? UNNotificationAttachment(identifier: "image",
url: url,
options: nil)
content.attachments = [attachment!]
contentHandler(content)
}
Media Attachment
Push
Local Notification
Remote Notification
let content = UNMutableNotificationContent()
let imagePath = Bundle.main.pathForResource("test", ofType: ".jpg")
let attachment = try? UNNotificationAttachment(identifier: "image",
url: URL(fileURLWithPath: imagePath!),
options: nil)
content.attachments = [attachment!]
{
"aps": {
"alert": "Someone chat to you.",
“mutable-content”:1
},
“attachment-url”:”…”
}
Notification User Interface
• Notification content extension
• Custom views
• No interactions
• Respond to notification actions
Implementation
Thanks

More Related Content

PDF
WSO2Con USA 2017: Identity and Access Management in the Era of Digital Transf...
PPTX
Android Starting App Development
ODP
Authentication and Single Sing on
PPTX
Single sign on - benefits, challenges and case study : iFour consultancy
PPTX
12 ibm connections integration
PPTX
Asp.net membership anduserroles_ppt
PPT
Fast and Free SSO: A Survey of Open-Source Solutions to Single Sign-on
PDF
Advanced rich push notifications
WSO2Con USA 2017: Identity and Access Management in the Era of Digital Transf...
Android Starting App Development
Authentication and Single Sing on
Single sign on - benefits, challenges and case study : iFour consultancy
12 ibm connections integration
Asp.net membership anduserroles_ppt
Fast and Free SSO: A Survey of Open-Source Solutions to Single Sign-on
Advanced rich push notifications

Viewers also liked (14)

PPTX
Bolts Framework
PPTX
Push notifications Зачем и почему?
PPTX
iOS 10 Rich Push Notifications
PPTX
Brug - Web push notification
PDF
What make Swift Awesome
PPTX
Speech Recognition API
PDF
Push Notifications
PDF
Algoritma perulangan
PDF
Web Push Notifications
PPTX
3D Video Processing - BBS
PDF
Юрий Василевский — Сервис пуш-сообщений Яндекса
PPT
Web Push уведомления - успешные кейсы, проблемы и статистика инструмента
PPTX
Introduction to Firebase [Google I/O Extended Bangkok 2016]
PDF
The Best Mobile App Marketing of 2016
Bolts Framework
Push notifications Зачем и почему?
iOS 10 Rich Push Notifications
Brug - Web push notification
What make Swift Awesome
Speech Recognition API
Push Notifications
Algoritma perulangan
Web Push Notifications
3D Video Processing - BBS
Юрий Василевский — Сервис пуш-сообщений Яндекса
Web Push уведомления - успешные кейсы, проблемы и статистика инструмента
Introduction to Firebase [Google I/O Extended Bangkok 2016]
The Best Mobile App Marketing of 2016
Ad

Similar to Notification Framework (20)

PDF
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
PDF
iOS Remote Notifications
PDF
What's new in iOS Push Notifications
PDF
Improving apps with iOS 10 notifications (do iOS 2016)
PPTX
Push Notification
PDF
Get step-by-step instructions on implementing notifications in your apps.
PPTX
2017 eics-lbr-xdn tool-presentation
KEY
Local Notifications @ Melbourne Cocoaheads (Aug 10)
PDF
How to Enable Unified Push Notifications in Native and HTML5 Hybrid Mobile Apps
PPTX
Events vs Notifications
PDF
Push to Engage
PDF
Actor based approach in practice for Swift developers
PPTX
Push_notifikacije_na_Azureu[1]
PPTX
Automating the Gaps of Unit Testing Mobile Apps
PDF
Distributing information on iOS
PPTX
ReactNYC: Push Notifications in React Native
PPTX
Azure notification hubs
PPTX
Android notifications. testing guideline
PPTX
Creating User Interface and Notification System in Flutter .pptx
PDF
Lime - Push notifications. The big way.
What's New in User Notifications Framework - WWDC16. Meetup @Wantedly with 日本...
iOS Remote Notifications
What's new in iOS Push Notifications
Improving apps with iOS 10 notifications (do iOS 2016)
Push Notification
Get step-by-step instructions on implementing notifications in your apps.
2017 eics-lbr-xdn tool-presentation
Local Notifications @ Melbourne Cocoaheads (Aug 10)
How to Enable Unified Push Notifications in Native and HTML5 Hybrid Mobile Apps
Events vs Notifications
Push to Engage
Actor based approach in practice for Swift developers
Push_notifikacije_na_Azureu[1]
Automating the Gaps of Unit Testing Mobile Apps
Distributing information on iOS
ReactNYC: Push Notifications in React Native
Azure notification hubs
Android notifications. testing guideline
Creating User Interface and Notification System in Flutter .pptx
Lime - Push notifications. The big way.
Ad

Notification Framework