ExTauri.Notification (ex_tauri v0.2.0)

View Source

Send native desktop notifications from your LiveView.

This module provides a simple API for sending OS-native notifications via the Tauri notification plugin, bridged through the LiveView hook.

Requirements

  • tauri-plugin-notification must be installed (included by mix ex_tauri.install)
  • The TauriHook must be mounted in your LiveView (see ExTauri.Hook)
  • The notification:default capability must be configured

Plugin Setup

This plugin is included by default when running mix ex_tauri.install. The notification:default capability is already configured in the generated src-tauri/capabilities/default.json. No additional setup needed.

Examples

# In a LiveView
def handle_event("save", _params, socket) do
  # ... save logic ...
  socket = ExTauri.Notification.send(socket, "Saved!", body: "Your changes have been saved.")
  {:noreply, socket}
end

# Handle the response
def handle_event("tauri_response", %{"command" => "notification"} = params, socket) do
  case params["status"] do
    "sent" -> {:noreply, socket}
    "denied" -> {:noreply, put_flash(socket, :error, "Notification permission denied")}
  end
end

Summary

Functions

Sends a native desktop notification.

Functions

send(socket, title, opts \\ [], on_reply \\ nil)

Sends a native desktop notification.

Options

  • :body - The notification body text
  • :icon - Path to a notification icon

Examples

ExTauri.Notification.send(socket, "Download Complete")
ExTauri.Notification.send(socket, "New Message", body: "You have 3 new messages")