pub struct Notification { /* private fields */ }
Available on desktop and crate feature notification only.
Expand description

The desktop notification definition.

Allows you to construct a Notification data and send it.

Examples

use tauri::api::notification::Notification;
// first we build the application to access the Tauri configuration
let app = tauri::Builder::default()
  // on an actual app, remove the string argument
  .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
  .expect("error while building tauri application");

// shows a notification with the given title and body
Notification::new(&app.config().tauri.bundle.identifier)
  .title("New message")
  .body("You've got a new message.")
  .show();

// run the app
app.run(|_app_handle, _event| {});

Implementations§

Initializes a instance of a Notification.

Sets the notification body.

Sets the notification title.

Sets the notification icon.

Shows the notification.

Examples
use tauri::api::notification::Notification;

// on an actual app, remove the string argument
let context = tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json");
Notification::new(&context.config().tauri.bundle.identifier)
  .title("Tauri")
  .body("Tauri is awesome!")
  .show()
  .unwrap();
Platform-specific
  • Windows: Not supported on Windows 7. If your app targets it, enable the windows7-compat feature and use Self::notify.
Available on crate feature windows7-compat only.

Shows the notification. This API is similar to Self::show, but it also works on Windows 7.

Examples
use tauri::api::notification::Notification;

// on an actual app, remove the string argument
let context = tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json");
let identifier = context.config().tauri.bundle.identifier.clone();

tauri::Builder::default()
  .setup(move |app| {
    Notification::new(&identifier)
      .title("Tauri")
      .body("Tauri is awesome!")
      .notify(&app.handle())
      .unwrap();
    Ok(())
  })
  .run(context)
  .expect("error while running tauri application");

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more