Finally, Web Push API is available in all major browsers and platforms. It's a feature that can take your users' experience to the next level or... ruin it! In my session, after a tech intro about how Web Push works, we'll explore implementing smart permission request dialogues, various ...
Finally, Web Push API is available in all major browsers and platforms. It's a feature that can take your users' experience to the next level or... ruin it! In my session, after a tech intro about how Web Push works, we'll explore implementing smart permission request dialogues, various types of notifications themselves, and communicating with your app for more sophisticated scenarios - all done right, with the best possible UX.
Size: 831.84 KB
Language: en
Added: Apr 27, 2023
Slides: 22 pages
Slide Content
WEB PUSH
NOTIFICATIONS
DONE RIGHT
Maxim Salnikov
@webmaxru
What is web push
and how to start using it the right way
Maxim Salnikov
•Developer Engagement Lead at Microsoft
•Web Platform tech speaker, writer, trainer
TWITTER: @WEBMAXRU GITHUB: @WEBMAXRU SETTINGS
webmax.ru
IconTitleBody Actions Image
Why Push Notifications?
•Delivered regardless of app/browser state
•High opt-in (79.5%) and direct open (5%) rates*
•Delivery channel is free and reliable
•Rich format capabilities for better engagement
•Easy and fast to set up and start sending
*Data: Airship 2023 Push Notification Benchmarks, median for Android
Milestones
2000
Push Service in
Blackberry –
instant
notification
about a new
email received
2009
Apple Push
Notification
Service on iOS
3.0
Google’s
Android Cloud
To Device
Messaging
2013
Google Cloud
Messaging for
Chrome Apps
and Extensions
APNS for Safari
on OS X 10.9
2015
Web Push API in
Chrome 42
Web Push API in
Firefox 44
Windows
Notification
Service extended
2023
In production on
all major
platforms –after
iOS 16.4 and
Safari on macOS
13 joined.
https://caniuse.com/push-api
80%
of the users
Availability
Web Push prerequisites
•Notifications API and Web Push API are available
•Service Worker is registered and active
•Valid code for the “push” event
•Notifications are allowed for the origin and browser
•On iOS: app is added to the Home Screen
•Device is online
Politeness is a must
•Consider alternatives first
•Initiate subscription flow only after explicituser action
•Show pre-request UI with a content and frequency explained
•Confirm by UI that unsubscribing is possible at any time
•Separate notification permission request and subscription
Requesting permission
Notification.requestPermission().then((result) =>{
if(result !== 'granted') {
// Plan B on convincing user needed
} else{
// OK to proceed with subscription
}
});
Your best notification
•Transactional, not promotional
•Timely, personal, relevant
•Contains information itself, not just “click to see”
•Contains call-to-action
•Does not repeat itself
•Use emoji??????
Your OSL->LHR flight✈️
Click here to check-in
fooairline.com
FooAirlineltd.
Online check-in is available
fooairline.com
You can use “push” event to
•Fetch extra data from the backend to use in the notification
•Message a client –for example, to update app UI or icon via
Badging API
•Gather analytics
•Call self.registration.showNotification()–it’s the
only required action
In the service worker
self.addEventListener('push', (event) =>{
notification = event.data.json();
constshowNotificationPromise= self.registration.showNotification(
notificationData.title,
notificationData
);
constpromiseChain= Promise.allSettled([
messageClientPromise,
showNotificationPromise,
]);
event.waitUntil(promiseChain);
});
Use “notificationclick” to
•Open a browser or installed app
•Focus an existing tab with the app
•Use feature detection to check if multiple actions are
available
if('actions'inwindow.Notification?.prototype) {}
•Attach analytics code
Summary
•Web Push feature is very
powerful for the businesses and
convenient for the users
•Currently available on all major
platforms
•To keep it relevant, it’s
important to avoid misusing
•Services like OneSignal, Pusher,
Airship etc. can help with a
backend component (and not
only)
IMAGE: PUSH NOTIFICATIONS UI KIT BY ONESIGNAL
Instant Web Push
notification test
-Playground for the Web Push API
-Entire flow from requesting permission to
sending the notification
-Sending to multiple devices
-Specifications, API references, guides + this
deck
HTTPS://PUSH.FOO