ExTauri.Notification (ex_tauri v0.2.0)
View SourceSend 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-notificationmust be installed (included bymix ex_tauri.install)- The
TauriHookmust be mounted in your LiveView (seeExTauri.Hook) - The
notification:defaultcapability 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.