Notification
Schedules and manages notifications.
Notifications are scheduled for delivery at some point in the future. A notification may be delivered even when Scriptable is not running.
Properties
Section titled “Properties”actions
Section titled “actions”Actions added to the notification.
actions: {string: string}An array of objects on the following form:
{ "title": "Open Website", "url": "https://scriptable.app"}To add a notification, use Notification.addAction.
Read-only.
Number to display in the app icon’s badge.
badge: numberWhen the number is zero, no badge is displayed. When the number is greater than zero, the number is displayed in the app icon’s badge. Setting the value to null, will leave the badge unchanged. The default value is null.
Body of the notification.
body: stringdeliveryDate
Section titled “deliveryDate”Delivery date of the notification.
deliveryDate: DateIf the notification has already been delivered, for example because it was fetched using Notification.allDelivered(), the deliveryDate will be populated. Otherwise it will be null.
The property cannot be set. In order to specify a future delivery date for a notification, see the setTriggerDate function. For recurring notifications, see the setDailyTrigger and setWeeklyTrigger functions.
Read-only.
identifier
Section titled “identifier”Identifier of the notification.
identifier: stringTo reschedule a notification, use the identifier of an existing notification.
nextTriggerDate
Section titled “nextTriggerDate”Next trigger date of the notification.
nextTriggerDate: DateThe next trigger date is the point in time where the next notification will be delivered.
The property cannot be set. In order to specify a future delivery date for a notification, see the setTriggerDate function. For recurring notifications, see the setDailyTrigger and setWeeklyTrigger functions.
Read-only.
openURL
Section titled “openURL”URL to open when notification is tapped.
openURL: stringThe Scriptable application will open the URL when the notification is tapped. This can be a URL that uses Scriptables URL scheme, the URL scheme of another application or a website URL.
preferredContentHeight
Section titled “preferredContentHeight”Preferred height of the notification.
preferredContentHeight: numberBy default Scriptable attempts to determine an appropriate height for your notification. If you want to override the default behavior, you can specify a preferred content height. The preferred content height is only used when running a script inside the notification, i.e. when scriptName is not null. iOS may limit the height of the notification in which case the preferred content height is not guaranteed to be respected.
scriptName
Section titled “scriptName”Name of script to run in rich notification.
scriptName: stringWhen notification is force touched or long pressed, Scriptable can run a script inside the notification without opening the app. Set the scriptName to a name of an existing script to run it inside the notification.
Sound of the notification.
sound: stringSet to null if you do not want any sound. Set to one of the following values if you want a sound.
- default
- accept
- alert
- complete
- event
- failure
- piano_error
- piano_success
- popup
By default the notification is delivered with no sound.
subtitle
Section titled “subtitle”Subtitle of the notification.
subtitle: stringthreadIdentifier
Section titled “threadIdentifier”Identifier for grouping the notification.
threadIdentifier: stringNotifications are grouped by the identifier on the Home screen and in the Notification Center.
Title of the notification.
title: stringuserInfo
Section titled “userInfo”Custom information.
userInfo: {string: any}Store any custom information for the notification. This can be accessed from the Notification.opened property when a script is run from a notification.
Methods
Section titled “Methods”
new Notification()
Section titled “new Notification()”Constructs a notification.
new Notification()
addAction(title, url, destructive)
Section titled “addAction(title, url, destructive)”Adds an action button.
addAction(title: string, url: string, destructive: bool)Actions are shown as buttons in the notification. When screen space is unlimited, the system shows up to 10 actions. When the space is limited the system shows at most two actions.
Parameters
Section titled “Parameters”title string
Title of the action.
url string
URL to open when choosing the action.
destructive bool
Optional. If set to true, the button is displayed with special highlighting to indicate that it performs a destructive task. Defaults to false.
allDelivered()
Section titled “allDelivered()”Delivered notifications displayed in the Notification Center.
static allDelivered(): Promise<[Notification]>Fetches all notifications that have been scheduled from Scriptable and that are still displayed in the Notification Center of iOS.
Return value
Section titled “Return value”Promise<[Notification]>
Promise that carries all delivered notifications when fulfilled.
allPending()
Section titled “allPending()”All pending notifications.
static allPending(): Promise<[Notification]>Fetches all notifications that have been scheduled from Scriptable and are waiting to be delivered.
Return value
Section titled “Return value”Promise<[Notification]>
Promise that carries all pending notifications when fulfilled.
current()
Section titled “current()”Notification a script is running in.
static current(): NotificationThe notification that a script is being run in or the application was opened from.
The notification contains all information that was set when the notification was originally scheduled, including the userInfo property which can be used to contain custom data that might be relevant when running the script.
Return value
Section titled “Return value”Notification
The notification that a script is running in.
remove()
Section titled “remove()”Removes the notification.
remove(): PromiseRemoves all future triggers of the notification.
Return value
Section titled “Return value”Promise
Promise that is fulfilled when the notification have been removed.
removeAllDelivered()
Section titled “removeAllDelivered()”Removes all delivered notifications.
static removeAllDelivered(): PromiseRemoves all notifications that have been scheduled from Scriptable and that are still displayed in the Notification Center of iOS.
Return value
Section titled “Return value”Promise
Promise that is fulfilled when the notifications have been removed.
removeAllPending()
Section titled “removeAllPending()”Removes all pending notifications.
static removeAllPending(): PromiseRemoves all notifications that have been scheduled from Scriptable and are waiting to be delivered.
Use with caution. This removes all notifications scheduled across all of your scripts and the action cannot be undone.
Return value
Section titled “Return value”Promise
Promise that is fulfilled when the notifications have been removed.
removeDelivered(identifiers)
Section titled “removeDelivered(identifiers)”Removes delivered notifications.
static removeDelivered(identifiers: [string]): PromiseRemoves notifications with the specified identifiers. The notifications are only removed if they have been delivered. To remove pending notifications, see Notification.removePending().
Parameters
Section titled “Parameters”identifiers [string]
Return value
Section titled “Return value”Promise
Promise that is fulfilled when the notifications have been removed.
removePending(identifiers)
Section titled “removePending(identifiers)”Removes pending notifications.
static removePending(identifiers: [string]): PromiseRemoves notifications with the specified identifiers. The notifications are only removed if they are pending, that is they have been scheduled and are waiting to be delivered. To remove delivered notifications, see Notification.removeDelivered().
Parameters
Section titled “Parameters”identifiers [string]
Return value
Section titled “Return value”Promise
Promise that is fulfilled when the notifications have been removed.
resetCurrent()
Section titled “resetCurrent()”Resets the current notification.
static resetCurrent()Effectively sets args.notification to null.
When a notification scheduled from Scriptable has been tapped to open the app or while the app was open, args.notification will have a value until Scriptable is quit. You can manually reset the value using Notification.resetCurrent.
schedule()
Section titled “schedule()”Schedules the notification.
schedule(): PromiseWhen a new notification is constructed, it must be scheduled, otherwise it will not be delivered. If an existing notification is modified, it must also be scheduled again for the changes to take effect.
Return value
Section titled “Return value”Promise
Promise that is fulfilled when the notification have been scheduled.
setDailyTrigger(hour, minute, repeats)
Section titled “setDailyTrigger(hour, minute, repeats)”Sets the notification to be triggered daily.
setDailyTrigger(hour: number, minute: number, repeats: bool)Sets the notification to be triggered on a specific time of the day. When the notification repeats, it will be sent at the same time on all future days. If the notification is not repating it will be sent on the next occurrence of the specified time.
Parameters
Section titled “Parameters”hour number
Hour of the day to trigger the notification.
minute number
Minute of the day to trigger the notification.
repeats bool
If true the notification will be sent daily on the specified time, otherwise it will only be sent once. Defaults to false.
setTriggerDate(date)
Section titled “setTriggerDate(date)”Sets the notification to be triggered on a date and time.
setTriggerDate(date: Date)Parameters
Section titled “Parameters”date Date
Date and time to trigger the notification on.
setWeeklyTrigger(weekday, hour, minute, repeats)
Section titled “setWeeklyTrigger(weekday, hour, minute, repeats)”Sets the notification to be triggered weekly.
setWeeklyTrigger(weekday: number, hour: number, minute: number, repeats: bool)Sets the notification to be triggered on a specific day of the week and a specific time of that day. When the notification repeats, it will be sent at the same time on all future days. If the notification is not repating it will be sent on the next occurrence of the specified time.
Parameters
Section titled “Parameters”weekday number
Day of the week to trigger the notification.
hour number
Hour of the day to trigger the notification.
minute number
Minute of the day to trigger the notification.
repeats bool
If true the notification will be sent daily on the specified time, otherwise it will only be sent once. Defaults to false.