Skip to main content

NotificationServicesPushController Actions

7 actions registered.

NameDeprecated
addPushNotificationLinks
deletePushNotificationLinks
disablePushNotifications
enablePushNotifications
getState
subscribeToPushNotifications
updateTriggerPushNotificationsYes

Package: @metamask/notification-services-controller

Adds backend push notification links for the given addresses using the current FCM token. This is used when accounts are added after push notifications have already been enabled, so backend can link the existing device token to the newly added addresses.

Parameters:

NameDescription
addressesAddresses that should be linked to push notifications.

Returns: Whether the add request succeeded.

Handler signature:

(addresses: string[]) => Promise<boolean>

Package: @metamask/notification-services-controller

Deletes backend push notification links for the given addresses on the current platform. This is used when accounts are removed (for example SRP removal), so backend can remove all associated FCM tokens for those address/platform pairs.

Parameters:

NameDescription
addressesAddresses that should be unlinked from push notifications.

Returns: Whether the delete request succeeded.

Handler signature:

(addresses: string[]) => Promise<boolean>

NotificationServicesPushController:disablePushNotifications​

Package: @metamask/notification-services-controller

Disables push notifications for the application. This removes the registration token on this device, and ensures we unsubscribe from any listeners

Handler signature:

() => Promise<void>

NotificationServicesPushController:enablePushNotifications​

Package: @metamask/notification-services-controller

Enables push notifications for the application.

This method sets up the necessary infrastructure for handling push notifications by:

  1. Registering the service worker to listen for messages.
  2. Fetching the Firebase Cloud Messaging (FCM) token from Firebase.
  3. Sending the FCM token to the server responsible for sending notifications, to register the device.

Parameters:

NameDescription
addressesAn array of addresses to enable push notifications for.

Handler signature:

(addresses: string[]) => Promise<void>

NotificationServicesPushController:getState​

Package: @metamask/notification-services-controller

Handler signature:

() => NotificationServicesPushControllerState

NotificationServicesPushController:subscribeToPushNotifications​

Package: @metamask/notification-services-controller

Handler signature:

() => Promise<void>

NotificationServicesPushController:updateTriggerPushNotifications​

Deprecated

Package: @metamask/notification-services-controller

Updates the triggers for push notifications. This method is responsible for updating the server with the new set of addresses that should trigger push notifications. It uses the current FCM token and a BearerToken for authentication. Deprecated: - this is not used anymore and will most likely be removed

Parameters:

NameDescription
addressesAn array of addresses that should trigger push notifications.

Handler signature:

(addresses: string[]) => Promise<void>