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 behaviour, 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 information. 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.

If the notification have 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.

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.

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.

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.

When a notification scheduled from Scriptable have been tapped to open the app or while the app was open, Notification.current will have a value until Scriptable is quit. You can manually reset the value using Notification.resetCurrent.

static current(): Notification

-new Notification

Constructs a notification.

new Notification()

-schedule

Schedules the notification.

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.

schedule(): Promise

-remove

Removes the notification.

Removes all future triggers of the notification.

remove(): Promise

-setTriggerDate

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

setTriggerDate(date: Date)

-setDailyTrigger

Sets the notification to be triggered daily.

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.

setDailyTrigger(hour: number, minute: number, repeats: bool)

-setWeeklyTrigger

Sets the notification to be triggered weekly.

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.

setWeeklyTrigger(weekday: number, hour: number, minute: number, repeats: bool)

-addAction

Adds an action button.

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.

addAction(title: string, url: string, destructive: bool)

+allPending

All pending notifications.

Fetches all notifications that have been scheduled from Scriptable and are waiting to be delivered.

static allPending(): Promise<[Notification]>

+allDelivered

Delivered notifications displayed in the Notification Center.

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

static allDelivered(): Promise<[Notification]>

+removeAllPending

Removes all pending notifications.

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.

static removeAllPending(): Promise

+removeAllDelivered

Removes all delivered notifications.

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

static removeAllDelivered(): Promise

+removePending

Removes pending notifications.

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

static removePending(identifiers: [string]): Promise

+removeDelivered

Removes delivered notifications.

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

static removeDelivered(identifiers: [string]): Promise

+resetCurrent

Resets the current notification.

Effectively sets Notification.current to null.

When a notification scheduled from Scriptable have been tapped to open the app or while the app was open, Notification.current will have a value until Scriptable is quit. You can manually reset the value using Notification.resetCurrent.

static resetCurrent()