Notification
Schedule and manage local notifications
Notification allows you to schedule local notifications that appear even when the app is not running.
Use Notification to:
Examples
let notif = new Notification();
notif.title = "Reminder";
notif.body = "Don't forget to check in!";
await notif.schedule();let notif = new Notification();
notif.title = "Daily Reminder";
notif.body = "Time for your daily task";
notif.setDailyTrigger(9, 0, true); // 9:00 AM daily
await notif.schedule();Properties
identifier
- Type:
String
Unique notification identifier
notif.identifiertitle
- Type:
String
Notification title
notif.title = "Title"subtitle
- Type:
String
Notification subtitle
notif.subtitle = "Subtitle"body
- Type:
String
Notification body text
notif.body = "Body text"preferredContentHeight
- Type:
Double
Preferred content height for custom notification UI
badge
- Type:
NSNumber
App badge number
notif.badge = 5threadIdentifier
- Type:
String
Thread identifier for grouping notifications
notif.threadIdentifier = "group1"userInfo
- Type:
[String: Any]
Custom user info dictionary
notif.userInfo = { key: "value" }sound
- Type:
String
Notification sound
notif.sound = "default"openURL
- Type:
String
URL to open when notification is tapped
notif.openURL = "https://example.com"scriptName
- Type:
String
Script to run when notification is tapped
notif.scriptName = "MyScript"deliveryDate
- Type:
JSValue
Delivery date for delivered notifications
nextTriggerDate
- Type:
JSValue
Next trigger date for scheduled notifications
actions
- Type:
[[String: String]]
Notification actions
Methods
schedule
Schedule the notification
schedule(callback): voidcallback- Callback when scheduled
Returns: Promise that resolves when scheduled
Example:
await notif.schedule()remove
Remove this notification
remove(callback): voidcallback- Callback when removed
Returns: Promise that resolves when removed
Example:
await notif.remove()setTriggerDateWithTimestamp
Set trigger date
setTriggerDateWithTimestamp(timestamp): voidtimestamp- JavaScript timestamp in milliseconds
Example:
notif.setTriggerDate(new Date(Date.now() + 60000))setDailyTrigger
Set daily trigger
setDailyTrigger(hour, minute, repeats): voidhour- Hour (0-23)minute- Minute (0-59)repeats- Whether to repeat daily
Example:
notif.setDailyTrigger(9, 0, true)setWeeklyTrigger
Set weekly trigger
setWeeklyTrigger(weekday, hour, minute, repeats): voidweekday- Day of week (1=Sunday, 7=Saturday)hour- Hour (0-23)minute- Minute (0-59)repeats- Whether to repeat weekly
Example:
notif.setWeeklyTrigger(2, 9, 0, true)addAction
Add notification action button
addAction(title, url, destructive): voidtitle- Button titleurl- URL to open when tappeddestructive- Show as destructive action
Example:
notif.addAction("Open", "myapp://action", false)allPending
Get all pending notifications
static allPending(): voidExample:
let pending = await Notification.allPending()allDelivered
Get all delivered notifications
static allDelivered(): voidExample:
let delivered = await Notification.allDelivered()removeAllPending
Remove all pending notifications
static removeAllPending(): voidExample:
await Notification.removeAllPending()removeAllDelivered
Remove all delivered notifications
static removeAllDelivered(): voidExample:
await Notification.removeAllDelivered()removePending
Remove specific pending notifications
static removePending(): voidExample:
await Notification.removePending(["id1", "id2"])removeDelivered
Remove specific delivered notifications
static removeDelivered(): voidExample:
await Notification.removeDelivered(["id1", "id2"])resetCurrent
Reset current notification context
static resetCurrent(): void