notification - Notifications
Notifications are messages displayed in the notification bar. Users can tap a notification to open the app or trigger an action.
This module provides the ability to display notifications, listen to notifications of other applications, and more, if users have permission.
Import this module via const notification = require("notification").
Table of contents
Interfaces
Functions
Functions
cancel
cancel(id: number): void
Cancel a notification by id. This only cancels notifications created by this app via notify.
To observe or cancel notifications from other apps, request notification-listening permission.
Parameters
id: Notification id used innotify.
Returns
void
notify
notify(id: number, n: BuildNotificationOptions ): void
Create and show a notification. id is the unique identifier: calling notify again with the same id updates the existing notification. Use cancel(id) to remove it.
Example
"nodejs";
const notification = require("notification");
const notificationId = 10001;
notification.notify(notificationId, {
contentTitle: "Tap to trigger a new notification",
contentText: "This notification cannot be dismissed by the user",
ticker: "New notification received",
onContentClick: () => {
showCounterNotification(0);
},
ongoing: true,
autoCancel: true,
});Parameters
id: Notification id. To avoid conflicts with Auto.js internal notifications, consider using ids starting from 10,000.n: Notification options (title, content, click handlers, etc.).
Returns
void
