Push-notifications for

Содержание

Слайд 2

Pavel Uvarov,
Software Engineer at Epam Ryazan
pavel_uvarov@epam.com

spiderpoul

poul_uvarov

Pavel Uvarov, Software Engineer at Epam Ryazan pavel_uvarov@epam.com spiderpoul poul_uvarov

Слайд 3

Agenda

What is PWA
How Web Push works
PWA example (Node.js, React)
Restrictions and future of

Agenda What is PWA How Web Push works PWA example (Node.js, React)
PWA
QA

Слайд 5

What is PWA?

Progressive Web Apps are web apps that use emerging web browser

What is PWA? Progressive Web Apps are web apps that use emerging
APIs and features along with traditional progressive enhancement strategy to bring a native app-like user experience to cross-platform web applications.

Слайд 6

Was Steve Jobs the first to introduce the concept of PWAs?

Was Steve Jobs the first to introduce the concept of PWAs?

Слайд 7

PWAs solve customer needs

Installable  - installed PWA run in a standalone window

PWAs solve customer needs Installable - installed PWA run in a standalone
instead of a browser tab. They're launchable from on the user's home screen.
Reliable - PWA can works offline.
Engaging -  Having an icon on the home screen makes it easy to get into the app and push notifications can help alert the user of important information that requires their attention.
Responsive - should be able to adapt to different screen sizes and orientations

Слайд 8

One app, every platform

One app, every platform

Слайд 9

One app, every platform

PWA are more affordable to develop and integrate than

One app, every platform PWA are more affordable to develop and integrate
native mobile apps
PWAs do not need to be updated

Слайд 10

Who is already using PWA?

Twitter saw a 65% increase in pages per

Who is already using PWA? Twitter saw a 65% increase in pages
session, 75% more Tweets, and a 20% decrease in bounce rate, all while reducing the size of their app by over 97%.
Nikkei saw 2.3 times more organic traffic, 58% more subscriptions, and 49% more daily active users.
Hulu replaced their platform-specific desktop experience with a Progressive Web App and saw a 27% increase in return visits.

Слайд 11

PWAs leverage modern web capabilities

PWAs leverage modern web capabilities

Слайд 12

Progressive Web App checklist

Use a secure connection (HTTPS)
Registers a service worker
Manifest file
Cross

Progressive Web App checklist Use a secure connection (HTTPS) Registers a service
browser support
Responsive to any screen size
Is installable
Provides an offline experience
Provides context for permission requests

Слайд 13

Push Notifications

System level notifications, like native apps
Fresh content that engages users
Works even

Push Notifications System level notifications, like native apps Fresh content that engages
when page is closed
Push Notifications are assembled using two APIs: the Notifications API and the Push API.

Слайд 14

Request permission

Request permission

Слайд 16

How Web Push works

Each browser manages push notifications through their own system,

How Web Push works Each browser manages push notifications through their own
called a "push service". 
This creates a special subscription object that contains the "endpoint URL" of the push service.
You send your push messages to this URL, encrypted with the public key, and the push service sends it to the right client
The endpoint URL contains a unique identifier

Слайд 17

How Web Push works

On the client:
Subscribe to the push service
Send the subscription

How Web Push works On the client: Subscribe to the push service
object to the server
On the server:
Generate the data that we want to send to the user
Encrypt the data with the user public key
Send the data to the endpoint URL with a payload of encrypted data.

Слайд 19

The subscription object

The subscription object

Слайд 20

Send a push notification

Send a push notification

Слайд 21

Send a push from server

Send a push from server

Слайд 22

What is VAPID?

Web Push Protocol not requiring strong authentication between your app and

What is VAPID? Web Push Protocol not requiring strong authentication between your
the push service
Publisher optionally identify themselves using the Voluntary Application Server Identification for Web Push (VAPID) protocol.
This provides a stable identity for the application serve

Слайд 24

What app should do

Login/Sign in for new users
Show notification for concrete user
Should

What app should do Login/Sign in for new users Show notification for
show notification on desktop and mobile simultaneously
1 hour reminder
https://hawkins-levels-tracker.now.sh/

Слайд 25

Tech Stack

Serverless functions
Node.js
FaunaDB
CRA
TS
Auth verified by JWT
SWR
Web push
Deployed by Vercel

https://github.com/spiderpoul/hawkins-levels-tracker

Tech Stack Serverless functions Node.js FaunaDB CRA TS Auth verified by JWT

Слайд 26

CRA PWA

https://create-react-app.dev/docs/making-a-progressive-web-app/

CRA PWA https://create-react-app.dev/docs/making-a-progressive-web-app/

Слайд 27

manifest.json

manifest.json

Слайд 28

Demo

https://hawkins-levels-tracker.now.sh/
Show on mobile
Notifications on both platforms
Show project, what makes it PWA, CRA

Demo https://hawkins-levels-tracker.now.sh/ Show on mobile Notifications on both platforms Show project, what
service workers, manifest.json

Слайд 36

PWA limitations

Still a new technology – all browsers don't support it fully

PWA limitations Still a new technology – all browsers don't support it
yet
More limited hardware access
Limited performance for computation heavy operations – although WebAssembly is improving this
High battery usage

Слайд 37

Links

https://developers.google.com/web/ilt/pwa/introduction-to-progressive-web-app-architectures
https://web-push-book.gauntface.com/
https://medium.com/progressivewebapps/history-of-progressive-web-apps-4c912533a531
https://serviceworke.rs/push-simple.html
https://web.dev/progressive-web-apps/

Links https://developers.google.com/web/ilt/pwa/introduction-to-progressive-web-app-architectures https://web-push-book.gauntface.com/ https://medium.com/progressivewebapps/history-of-progressive-web-apps-4c912533a531 https://serviceworke.rs/push-simple.html https://web.dev/progressive-web-apps/