Skip to content

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.

identifier

Identifier of the notification.

To reschedule a notification, use the identifier of an existing notification.

identifier: string

title

Title of the notification.

title: string

subtitle

Subtitle of the notification.

subtitle: string

body

Body of the notification.

body: string

preferredContentHeight

Preferred height of the notification.

By 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.

preferredContentHeight: number

badge

Number to display in the app icon's badge.

When 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.

badge: number

threadIdentifier

Identifier for grouping the notification.

Notifications are grouped by the identifier on the Home screen and in the Notification Center.

threadIdentifier: string

userInfo

Custom information.

Store any custom information for the notification. This can be accessed from the Notification.opened property when a script is run from a notification.

userInfo: {string: any}

sound

Sound of the notification.

Set 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.

sound: string

openURL

URL to open when notification is tapped.

The 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.

openURL: string

deliveryDate

Delivery date of the notification.

Read-only.

If 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.

deliveryDate: Date

nextTriggerDate

Next trigger date of the notification.

Read-only.

The 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.

nextTriggerDate: Date

scriptName

Name of script to run in rich notification.

When 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.

scriptName: string

actions

Actions added to the notification.

Read-only.

An array of objects on the following form:

{
  "title": "Open Website",
  "url": "https://scriptable.app"
}

To add a notification, use Notification.addAction.

actions: {string: string}

+current

Notification a script is running in.

Deprecated in version 1.3. Use args.notification instead.

static current(): Notification

The 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

Notification
The notification that a script is running in.


-new Notification

Constructs a notification.

new Notification()

-schedule

Schedules the notification.

schedule(): Promise

When 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

Promise
Promise that is fulfilled when the notification have been scheduled.


-remove

Removes the notification.

remove(): Promise

Removes all future triggers of the notification.

Return value

Promise
Promise that is fulfilled when the notification have been removed.


-setTriggerDate

Sets the notification to be triggered on a date and time.

setTriggerDate(date: Date)

Parameters

date
Date
Date and time to trigger the notification on.


-setDailyTrigger

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

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.


-setWeeklyTrigger

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

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.


-addAction

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

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.


+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

Promise<[Notification]>
Promise that carries all pending notifications when fulfilled.


+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

Promise<[Notification]>
Promise that carries all delivered notifications when fulfilled.


+removeAllPending

Removes all pending notifications.

static removeAllPending(): Promise

Removes 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

Promise
Promise that is fulfilled when the notifications have been removed.


+removeAllDelivered

Removes all delivered notifications.

static removeAllDelivered(): Promise

Removes all notifications that have been scheduled from Scriptable and that are still displayed in the Notification Center of iOS.

Return value

Promise
Promise that is fulfilled when the notifications have been removed.


+removePending

Removes pending notifications.

static removePending(identifiers: [string]): Promise

Removes 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().

Return value

Promise
Promise that is fulfilled when the notifications have been removed.


+removeDelivered

Removes delivered notifications.

static removeDelivered(identifiers: [string]): Promise

Removes notifications with the specified identifiers. The notifications are only removed if they have been delivered. To remove pending notifications, see Notification.removePending().

Return value

Promise
Promise that is fulfilled when the notifications have been removed.


+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.