Js_of_ocaml.NotificationNotifications API.
A code example:
if Notification.is_supported ()
then
ignore
(Promise.map
(fun perm ->
if Js.to_string perm = "granted"
then
let options = Notification.empty_options () in
options##.body := Js.string "Hello from OCaml!";
ignore (new%js Notification.notification_with_options
(Js.string "Title") options))
(Notification.request_permission ()))class type notificationAction = object ... endA single action shown alongside a (persistent) notification. Used both when building notificationOptions and when reading notification's actions; the members are therefore read-write.
class type notificationOptions = object ... endInitializer for notification. All fields are optional; create an empty record with empty_options and populate the ones you need.
val empty_options : unit -> notificationOptions Js.tclass type notification = object ... endval notification : (Js.js_string Js.t -> notification Js.t) Js.constrval notification_with_options :
(Js.js_string Js.t ->
notificationOptions Js.t ->
notification Js.t)
Js.constrval permission : unit -> Js.js_string Js.tThe current permission to display notifications: "granted", "denied" or "default".
The maximum number of actions supported by notifications on this device.
val request_permission : unit -> Js.js_string Js.t Promise.tRequest permission from the user to display notifications. The promise resolves with the new permission value (see permission).