Notification
Local notification scheduling
Schedules a local notification with a title, body, sound and interactive actions. Fires after a delay or at a date.
Methods
Notification.schedule(options)StringSchedules a local notification and returns the id it used, so an auto-generated one can still be cancelled. Throws if title is missing.
- options Any required
- title String required
The heading.
- body String
The line under it.
- subtitle String
A second heading between title and body.
- id String
Your own identifier, for cancelling it later. Generated if absent.
- sound Boolean
Play the default sound.
- badge Number
Set the app icon badge.
- delay Duration
Fire after this long. Minimum one second.
- date DateTime
Fire at this moment. Ignored when delay is given.
- actions [Any]
Buttons, as [{ id, title }]. Tapping one runs the script with that id in Script.actions.
- title String required
Notification.cancel(id)Cancel a scheduled notification by ID.
- id String required
Notification.cancelAll()Cancel all scheduled notifications for this script.
Examples
Schedule a reminder
Notification.schedule({
id: "reminder",
title: "Time's up!",
body: "Your timer has finished.",
sound: "complete",
delay: Duration.minutes(5)
});