Skip to main content

Notifications

Methods related to notifications for the current user.

AddNotificationListener

AddNotificationListener(onMessage) → Promise.<EventSource>

Add a listener to receive new notifications.

Returns: An EventSource instance listening for notifications. Use source.close() to close the listener.

Parameters

NameTypeRequiredDescription
onMessagefunction

Callback invoked when a new notification is received

Notifications

Notifications(
  limit, // optional
  tenantId, // optional
  types, // optional
  offsetId // optional
) → Promise.<Array.<Object>>

Retrieve notifications for the current user.

Returns: A list of notifications for the specified parameters

Parameters

NameTypeRequiredDescription
limitinteger

The maximum number of notifications to return

(default: 10)
tenantIdstring

Filter notifications to only those related to the specified tenant

typesArray.<string>

Filter notifications to only the specified types

offsetIdstring

Return notifications older than the specified ID

PushNotification

PushNotification(
  tenantId,
  eventType,
  data, // optional
  userAddress // optional
)

Push a notification to a user

Parameters

NameTypeRequiredDescription
tenantIdstring

The tenant associated with this notification

eventTypestring

The type of the notification

dataObject | string

Data associated with this notification

userAddressstring

Address of the user to notify. If not specified, it will be sent to the current user.