Module notifications

Module notifications 

Source
Expand description

Chrome system notification API, allows creation of desktop / system notifications.

§Synopsis

use nw_sys::notifications;

// Create basic notification
let options = notifications::Options::new()
    .title("Title text")
    .icon_url("/resources/icons/tray-icon@2x.png")
    .set_type(notifications::TemplateType::Basic)
    .message("Message Text")
    .context_message("Context Message");

notifications::create(None, &options, None);

// Create notification with buttons
let button1 = notifications::Button::new()
    .title("Button A")
    .icon_url("/resources/icons/tray-icon@2x.png");

let button2 = notifications::Button::new()
    .title("Button B")
    .icon_url("/resources/icons/tray-icon@2x.png");

let options = notifications::Options::new()
    .title("Title text")
    .icon_url("/resources/icons/tray-icon@2x.png")
    .set_type(notifications::TemplateType::Basic)
    .message("Message Text")
    .buttons(vec![button1, button2]);

notifications::create(None, &options, None);

// Create image notification
let options = notifications::Options::new()
    .title("Title text")
    .icon_url("/resources/icons/tray-icon@2x.png")
    .set_type(notifications::TemplateType::Image)
    .message("Message Text")
    .image_url("/resources/setup/document.png");

notifications::create(None, &options, None);

// Create notification with items
let item1 = notifications::Item::new()
    .title("Item A")
    .message("Mesage A");
let item2 = notifications::Item::new()
    .title("Item B")
    .message("Mesage B");

let options = notifications::Options::new()
    .title("Title text")
    .icon_url("/resources/icons/tray-icon@2x.png")
    .set_type(notifications::TemplateType::List)
    .message("Message Text")
    .items(vec![item1, item2]);

notifications::create(None, &options, None);

// Create notification with progress
let options = notifications::Options::new()
    .title("Title text")
    .icon_url("/resources/icons/tray-icon@2x.png")
    .set_type(notifications::TemplateType::Progress)
    .message("Mesage text")
    .progress(50);
notifications::create(None, &options, None);
  

Structs§

Button
Notification Button
Item
Notification Item
Options
Notification Options

Enums§

TemplateType
Notification template type

Functions§

clear
Clears the specified notification.
create
Creates and displays a notification.
get_all
Retrieves all the notifications of this app or extension.
get_permission_level
Retrieves whether the user has enabled notifications from this app or extension.
on_button_clicked
The user pressed a button in the notification.
on_clicked
The user clicked in a non-button area of the notification.
on_closed
The notification closed, either by the system or by user action.
on_permission_level_changed
The user changes the permission level. As of Chrome 47, only ChromeOS has UI that dispatches this event.
update
Updates an existing notification.