diff --git a/v3/examples/notifications/frontend/bindings/github.com/wailsapp/wails/v3/pkg/services/notifications/models.js b/v3/examples/notifications/frontend/bindings/github.com/wailsapp/wails/v3/pkg/services/notifications/models.js index c52cbf1c2..1b53de966 100644 --- a/v3/examples/notifications/frontend/bindings/github.com/wailsapp/wails/v3/pkg/services/notifications/models.js +++ b/v3/examples/notifications/frontend/bindings/github.com/wailsapp/wails/v3/pkg/services/notifications/models.js @@ -11,7 +11,7 @@ import {Create as $Create} from "@wailsio/runtime"; * @typedef {Object} NotificationAction * @property {string} [id] * @property {string} [title] - * @property {boolean} [destructive] - macOS only + * @property {boolean} [destructive] - (macOS-specific) */ /** @@ -29,7 +29,7 @@ import {Create as $Create} from "@wailsio/runtime"; * @typedef {Object} NotificationOptions * @property {string} [id] * @property {string} [title] - * @property {string} [subtitle] + * @property {string} [subtitle] - (macOS-specific) * @property {string} [body] * @property {string} [categoryId] * @property {{ [_: string]: any }} [data] diff --git a/v3/examples/notifications/frontend/bindings/github.com/wailsapp/wails/v3/pkg/services/notifications/service.js b/v3/examples/notifications/frontend/bindings/github.com/wailsapp/wails/v3/pkg/services/notifications/service.js index ef81ee81a..85e54340f 100644 --- a/v3/examples/notifications/frontend/bindings/github.com/wailsapp/wails/v3/pkg/services/notifications/service.js +++ b/v3/examples/notifications/frontend/bindings/github.com/wailsapp/wails/v3/pkg/services/notifications/service.js @@ -16,7 +16,8 @@ import {Call as $Call, Create as $Create} from "@wailsio/runtime"; import * as $models from "./models.js"; /** - * CheckNotificationAuthorization checks current notification permission status. + * CheckNotificationAuthorization is a Windows stub that always returns true. + * (user authorization is macOS-specific) * @returns {Promise & { cancel(): void }} */ export function CheckNotificationAuthorization() { @@ -47,7 +48,8 @@ export function RegisterNotificationCategory(category) { } /** - * RemoveAllDeliveredNotifications removes all delivered notifications. + * RemoveAllDeliveredNotifications is a Windows stub that always returns nil. + * (macOS-specific) * @returns {Promise & { cancel(): void }} */ export function RemoveAllDeliveredNotifications() { @@ -56,7 +58,8 @@ export function RemoveAllDeliveredNotifications() { } /** - * RemoveAllPendingNotifications removes all pending notifications. + * RemoveAllPendingNotifications is a Windows stub that always returns nil. + * (macOS-specific) * @returns {Promise & { cancel(): void }} */ export function RemoveAllPendingNotifications() { @@ -65,17 +68,29 @@ export function RemoveAllPendingNotifications() { } /** - * RemoveDeliveredNotification removes a delivered notification matching the unique identifier. - * @param {string} identifier + * RemoveDeliveredNotification is a Windows stub that always returns nil. + * (macOS-specific) + * @param {string} $0 * @returns {Promise & { cancel(): void }} */ -export function RemoveDeliveredNotification(identifier) { - let $resultPromise = /** @type {any} */($Call.ByID(149440045, identifier)); +export function RemoveDeliveredNotification($0) { + let $resultPromise = /** @type {any} */($Call.ByID(149440045, $0)); return $resultPromise; } /** - * RemoveNotificationCategory remove a previously registered NotificationCategory. + * RemoveNotification is a Windows stub that always returns nil. + * (Linux-specific) + * @param {string} identifier + * @returns {Promise & { cancel(): void }} + */ +export function RemoveNotification(identifier) { + let $resultPromise = /** @type {any} */($Call.ByID(3702062929, identifier)); + return $resultPromise; +} + +/** + * RemoveNotificationCategory removes a previously registered NotificationCategory. * @param {string} categoryId * @returns {Promise & { cancel(): void }} */ @@ -85,17 +100,19 @@ export function RemoveNotificationCategory(categoryId) { } /** - * RemovePendingNotification removes a pending notification matching the unique identifier. - * @param {string} identifier + * RemovePendingNotification is a Windows stub that always returns nil. + * (macOS-specific) + * @param {string} $0 * @returns {Promise & { cancel(): void }} */ -export function RemovePendingNotification(identifier) { - let $resultPromise = /** @type {any} */($Call.ByID(3872412470, identifier)); +export function RemovePendingNotification($0) { + let $resultPromise = /** @type {any} */($Call.ByID(3872412470, $0)); return $resultPromise; } /** - * RequestUserNotificationAuthorization requests permission for notifications. + * RequestUserNotificationAuthorization is a Windows stub that always returns true, nil. + * (user authorization is macOS-specific) * @returns {Promise & { cancel(): void }} */ export function RequestUserNotificationAuthorization() { @@ -104,7 +121,8 @@ export function RequestUserNotificationAuthorization() { } /** - * SendNotification sends a basic notification with a unique identifier, title, subtitle, and body. + * SendNotification sends a basic notification with a name, title, and body. All other options are ignored on Windows. + * (subtitle and category id are only available on macOS) * @param {$models.NotificationOptions} options * @returns {Promise & { cancel(): void }} */ @@ -117,6 +135,7 @@ export function SendNotification(options) { * SendNotificationWithActions sends a notification with additional actions and inputs. * A NotificationCategory must be registered with RegisterNotificationCategory first. The `CategoryID` must match the registered category. * If a NotificationCategory is not registered a basic notification will be sent. + * (subtitle and category id are only available on macOS) * @param {$models.NotificationOptions} options * @returns {Promise & { cancel(): void }} */ diff --git a/v3/examples/notifications/frontend/main.js b/v3/examples/notifications/frontend/main.js index 64624f34b..718a9fb4f 100644 --- a/v3/examples/notifications/frontend/main.js +++ b/v3/examples/notifications/frontend/main.js @@ -1,14 +1,13 @@ import * as Notifications from "./bindings/github.com/wailsapp/wails/v3/pkg/services/notifications/service"; -import { Events, System } from "@wailsio/runtime"; +import { Events } from "@wailsio/runtime"; const notificationsElement = document.getElementById('notifications'); window.sendNotification = async () => { const granted = await Notifications.RequestUserNotificationAuthorization(); if (granted) { - const id = System.IsWindows() ? "Wails Notification Demo" : crypto.randomUUID() await Notifications.SendNotification({ - id, + id: crypto.randomUUID(), title: "Title", body: "Body!", data: { @@ -33,10 +32,9 @@ window.sendComplexNotification = async () => { replyButtonTitle: "Reply", replyPlaceholder: "Reply to frontend...", }); - - const id = System.IsWindows() ? "Wails Notification Demo" : crypto.randomUUID() + await Notifications.SendNotificationWithActions({ - id, + id: crypto.randomUUID(), title: "Complex Frontend Notification", subtitle: "From: Jane Doe", body: "Is it rainging today where you are?",