Notification

Constructors

Link copied to clipboard
constructor(options: NotificationConstructorOptions = definedExternally)

Notification

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

A NotificationAction[] property representing the actions of the notification.

Link copied to clipboard

A string property representing the body of the notification.

Link copied to clipboard

A string property representing the close button text of the notification.

Link copied to clipboard

A boolean property representing whether the notification has a reply action.

Link copied to clipboard

A string property representing the reply placeholder of the notification.

Link copied to clipboard

A boolean property representing whether the notification is silent.

Link copied to clipboard

A string property representing the sound of the notification.

Link copied to clipboard

A string property representing the subtitle of the notification.

Link copied to clipboard

A string property representing the type of timeout duration for the notification. Can be 'default' or 'never'.

Link copied to clipboard

A string property representing the title of the notification.

Link copied to clipboard

A string property representing the custom Toast XML of the notification.

Link copied to clipboard

A string property representing the urgency level of the notification. Can be 'normal', 'critical', or 'low'.

Functions

Link copied to clipboard
fun addListener(event: NotificationEvent.ACTION, listener: (event: Event<*>, index: Double) -> Unit)
fun addListener(event: NotificationEvent.CLICK, listener: (event: Event<*>) -> Unit)
fun addListener(event: NotificationEvent.CLOSE, listener: (event: Event<*>) -> Unit)
fun addListener(event: NotificationEvent.FAILED, listener: (event: Event<*>, error: String) -> Unit)
fun addListener(event: NotificationEvent.REPLY, listener: (event: Event<*>, reply: String) -> Unit)
fun addListener(event: NotificationEvent.SHOW, listener: (event: Event<*>) -> Unit)
Link copied to clipboard
fun close()

Dismisses the notification.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun off(event: NotificationEvent.ACTION, listener: (event: Event<*>, index: Double) -> Unit)
fun off(event: NotificationEvent.CLICK, listener: (event: Event<*>) -> Unit)
fun off(event: NotificationEvent.CLOSE, listener: (event: Event<*>) -> Unit)
fun off(event: NotificationEvent.FAILED, listener: (event: Event<*>, error: String) -> Unit)
fun off(event: NotificationEvent.REPLY, listener: (event: Event<*>, reply: String) -> Unit)
fun off(event: NotificationEvent.SHOW, listener: (event: Event<*>) -> Unit)
Link copied to clipboard
fun on(event: NotificationEvent.ACTION, listener: (event: Event<*>, index: Double) -> Unit)

fun on(event: NotificationEvent.CLICK, listener: (event: Event<*>) -> Unit)

Emitted when the notification is clicked by the user.

fun on(event: NotificationEvent.CLOSE, listener: (event: Event<*>) -> Unit)

Emitted when the notification is closed by manual intervention from the user.

fun on(event: NotificationEvent.FAILED, listener: (event: Event<*>, error: String) -> Unit)

Emitted when an error is encountered while creating and showing the native notification.

fun on(event: NotificationEvent.REPLY, listener: (event: Event<*>, reply: String) -> Unit)

Emitted when the user clicks the "Reply" button on a notification with hasReply: true.

fun on(event: NotificationEvent.SHOW, listener: (event: Event<*>) -> Unit)

Emitted when the notification is shown to the user. Note that this event can be fired multiple times as a notification can be shown multiple times through the show() method.

Link copied to clipboard
fun once(event: NotificationEvent.ACTION, listener: (event: Event<*>, index: Double) -> Unit)
fun once(event: NotificationEvent.CLICK, listener: (event: Event<*>) -> Unit)
fun once(event: NotificationEvent.CLOSE, listener: (event: Event<*>) -> Unit)
fun once(event: NotificationEvent.FAILED, listener: (event: Event<*>, error: String) -> Unit)
fun once(event: NotificationEvent.REPLY, listener: (event: Event<*>, reply: String) -> Unit)
fun once(event: NotificationEvent.SHOW, listener: (event: Event<*>) -> Unit)
Link copied to clipboard
fun removeListener(event: NotificationEvent.ACTION, listener: (event: Event<*>, index: Double) -> Unit)
fun removeListener(event: NotificationEvent.CLICK, listener: (event: Event<*>) -> Unit)
fun removeListener(event: NotificationEvent.CLOSE, listener: (event: Event<*>) -> Unit)
fun removeListener(event: NotificationEvent.FAILED, listener: (event: Event<*>, error: String) -> Unit)
fun removeListener(event: NotificationEvent.REPLY, listener: (event: Event<*>, reply: String) -> Unit)
fun removeListener(event: NotificationEvent.SHOW, listener: (event: Event<*>) -> Unit)
Link copied to clipboard
Link copied to clipboard
fun show()

Immediately shows the notification to the user. Unlike the web notification API, instantiating a new Notification() does not immediately show it to the user. Instead, you need to call this method before the OS will display it.