use web/notifications
Dependencies: the
, of
, web/permissions
This wraps the Notification API.
Note that not all features are implemented: for example, you can’t use the actions
property to show buttons to the user.
That requires the use of a service worker, and I haven’t quite figured that out yet.
notifications.can?
( → t
)Prompts the user for permission to send notifications, and then returns true, false, or undefined depending on whether they granted, denied, or just closed the box. Note this will just return false immediately if you didn’t call this as a result of an user gesture.
notification.send
( o
options object t
title for notification → n
notification object )Sends a notification using the provided title t
and options object o
, returning the Notification
object.
As a shortcut, o
can be a string, in which case it is interpreted as the body
of the notification.
The available option for o
are described here.
TODO: #12 add support for actions
using service worker.
docs@04547c7