notification — Notifications on iOS

The notification module allows you to schedule notification messages that are shown in the iOS Notification Center. Scheduled notifications are delivered even when your script (or even the entire app) is no longer running.

It is also possible to attach a URL to a notification that is launched when the notification is activated (e.g. selected in Notification Center).

Functions in the notification module:

notification.schedule(message[, delay, sound_name, action_url])

Schedule a notification with the given message text.

delay is the time interval in seconds until the notification is delivered.

sound_name can be any of the bundled sound effects that are also available via the sound module. Use an empty string to schedule a silent notification. Using an non-existing sound effect (e.g. ‘default’) will result in the system’s standard alert sound being played.

With the action_url parameter, you can specify a URL that is opened when the notification is activated (e.g. by tapping it in Notification Center). Which app is used to open the URL depends on the URL’s scheme, e.g. for http: URLs, Safari is used.

notification.cancel(notification)

Cancel a notification that was previously scheduled.

The notification parameter is a dict that was either retrieved via get_scheduled() or returned from the schedule() function.

notification.cancel_all()

Cancel all previously scheduled notifications.

notification.get_scheduled()

Return a list of scheduled notifications.

The entries in the list are dicts that can be used as parameters for the cancel() function.