The system's own notifications from the page, Web Push for when the app is closed, and toast: the note inside the page that needs no permission.
Notifications
They belong to the system, so the reader is asked first, once.
notify.askAsks to show notifications: true if allowed. The browser remembers the answer; a refusal is changed in its site settings.
Permissionwhat notify.ask last said
not asked
Nothing has been asked yet in this visit.
notify.showA title and a line, shown by the system: through the service worker where the app has one, so it outlives the page.
Fall back to a toastwhen notifications are not allowed
what happened
Nothing shown yet.
In the page, and while it is closed
A toast needs nothing from the reader. A push needs a service worker and a server.
toasttoast(words, a second line, "error"): a note in the corner for four seconds. No permission, no service worker; it is above dialogs too.
Kind
0 shown
push.subscribe and push.unsubscribeWeb Push reaches a device while the app is closed. Mote does the device's half; sending is a server's work.
1
A built, installed appmote build writes the service worker that receives a push and shows it ({title, body, url} as JSON), and opens the app on a press. mote dev serves no service worker, so here the call says so.
2
A server's public keyThe server makes a key pair once (VAPID) and gives the page the public half.
3
The subscriptionpush.subscribe(key) gives this device's subscription as json. The server stores it and posts to its endpoint. With Mote's back end, notify.enable() and notify.send do all of this: see Back end.