On this page

push

Functions and constants for interacting with local, as well as Apple''s and Google''s push notification services. These API's only exist on mobile platforms. [icon:ios] [icon:android]

Functions

push.register(notifications: Record<string | number, unknown>, callback: (...args: unknown[]) => unknown)

Send a request for push notifications. Note that the notifications table parameter is iOS only and will be ignored on Android.

Parameters

  • notifications: Record<string | number, unknown> — The types of notifications to listen to. [icon:ios]
  • callback: (...args: unknown[]) => unknown — Register callback function.

push.set_listener(listener: (...args: unknown[]) => unknown)

Sets a listener function to listen to push notifications.

Parameters

  • listener: (...args: unknown[]) => unknown — Listener callback function.

push.set_badge_count(count: number)

Set the badge count for application icon. This function is only available on iOS. [icon:ios]

Parameters

  • count: number — Badge count

push.schedule(time: number, title: string, alert: string, payload: string, notification_settings: Record<string | number, unknown>): number, string

Local push notifications are scheduled with this function. The returned id value is uniquely identifying the scheduled notification and can be stored for later reference.

Parameters

  • time: number — Number of seconds into the future until the notification should be triggered.
  • title: string — Localized title to be displayed to the user if the application is not running.
  • alert: string — Localized body message of the notification to be displayed to the user if the application is not running.
  • payload: string — JSON string to be passed to the registered listener function.
  • notification_settings: Record<string | number, unknown> — Table with notification and platform specific fields

Returns

  • number — Unique id that can be used to cancel or inspect the notification
  • string — Error string if something went wrong, otherwise nil

push.cancel(id: number)

Use this function to cancel a previously scheduled local push notification. The notification is identified by a numeric id as returned by push.schedule().

Parameters

  • id: number — The numeric id of the local push notification

push.cancel_all_issued()

Use this function to cancel a previously issued local push notifications.

push.get_scheduled(id: number): Record<string | number, unknown>

Returns a table with all data associated with a specified local push notification. The notification is identified by a numeric id as returned by push.schedule().

Parameters

  • id: number — The numeric id of the local push notification.

Returns

  • Record<string | number, unknown> — Table with all data associated with the notification.

push.get_all_scheduled(): Record<string | number, unknown>

Returns a table with all data associated with all scheduled local push notifications. The table contains key, value pairs where the key is the push notification id and the value is a table with the notification data, corresponding to the data given by push.get_scheduled(id).

Returns

  • Record<string | number, unknown> — Table with all data associated with all scheduled notifications.