Wren

Module notification

System notifications (WHATWG Notifications API; src/page/notification.odin, the shell's notification_shell.odin; native/js/odin/web_notification.odin). A page shows one only when the user granted its origin the permission; the browser shows it with the system's notifications (gui_toolkit's platform.notify).

Exposed to: Window. Source: api/notification.widl.

Odin: import "wren:notification".

Functions

Notification_permission

string Notification_permission()

Notification.permission for the realm's origin: "default", "granted" or "denied".

Odin: notification.permission.

Host: Notification_permission :: proc(c: ^Call) -> string

Notification_ask

Promise Notification_ask()

Notification.requestPermission(): a promise of the state after (0 default, 1 granted, 2 denied). The user is asked only after a click or a key press of theirs on the page; otherwise the state stays what it is.

Odin: notification.ask.

Host: Notification_ask :: proc(c: ^Call) -> u64

Notification_show

u64 Notification_show(string title, string body, string tag, bool silent)

new Notification(title, {body, tag, silent}): the notification's id, 0 when it is not shown (no permission, no notification service on this system): the page's object then fires "error". A notification of the same tag replaces the one before it.

Odin: notification.show.

Host: Notification_show :: proc(c: ^Call, title: string, body: string, tag: string, silent: bool) -> u64

Notification_next

Promise Notification_next(u64 id)

What happens next to a shown notification: a promise of 2 (it is shown: the first answer), 0 (a click on it: the browser brings its tab up) or 1 (it is gone; nothing comes after).

Odin: notification.next.

Host: Notification_next :: proc(c: ^Call, id: u64) -> u64

Notification_close

void Notification_close(u64 id)

close(): the system takes it away.

Odin: notification.close.

Host: Notification_close :: proc(c: ^Call, id: u64)

Edit this page on GitHub