NotificationServicesController Actions
18 actions registered.
NotificationServicesController:checkAccountsPresence
Package: @metamask/notification-services-controller
Handler signature:
(accounts: string[]) => Promise<Record<string, boolean>>
NotificationServicesController:createOnChainTriggers
Package: @metamask/notification-services-controller
This creates/re-creates on-chain triggers defined in User Storage.
Action - Used during Sign In / Enabling of notifications.
Notification preferences are initialized only when
AuthenticatedUserStorageService has no stored preferences yet.
Existing preferences are left as-is.
Parameters:
| Name | Description |
|---|---|
opts | optional options to mutate this functionality |
opts.hasMarketingConsent | The user's marketing-consent flag. Used only during initialization to seed marketing push notifications. |
opts.productAnnouncementEnabled | The user's product-announcement flag. Used only during initialization to seed marketing in-app notifications. |
opts.registerPushNotifications | Whether to attempt FCM/device push registration. |
Returns: The updated or newly created user storage.
Handler signature:
(opts?: NotificationServicesControllerCreateOnChainTriggersOptions) => Promise<void>
NotificationServicesController:deleteNotificationById
Package: @metamask/notification-services-controller
Used to delete a notification by id.
Note: This function should only be used for notifications that are stored in this controller directly, currently only snaps notifications.
Parameters:
| Name | Description |
|---|---|
id | The id of the notification to delete. |
Handler signature:
(id: string) => Promise<void>
NotificationServicesController:deleteNotificationsById
Package: @metamask/notification-services-controller
Used to batch delete notifications by id.
Note: This function should only be used for notifications that are stored in this controller directly, currently only snaps notifications.
Parameters:
| Name | Description |
|---|---|
ids | The ids of the notifications to delete. |
Handler signature:
(ids: string[]) => Promise<void>
NotificationServicesController:disableAccounts
Package: @metamask/notification-services-controller
Disables wallet-activity subscriptions for the given accounts.
This only writes the Trigger API. The device's FCM links stay in place, because those links deliver every notification source for an address.
Action - When a user disables wallet activity for a given account.
Parameters:
| Name | Description |
|---|---|
accounts | The accounts whose wallet-activity subscriptions are disabled. |
Handler signature:
(accounts: string[]) => Promise<void>
NotificationServicesController:disableNotificationServices
Package: @metamask/notification-services-controller
Disables all MetaMask notifications for the user. This method ensures that the user is authenticated, retrieves all linked accounts, and disables on-chain triggers for each account. It also sets the global notification settings for MetaMask, feature announcements to false.
Handler signature:
() => Promise<void>
NotificationServicesController:disablePushNotifications
Package: @metamask/notification-services-controller
Public method to expose disabling push notifications
Handler signature:
() => Promise<void>
NotificationServicesController:enableAccounts
Package: @metamask/notification-services-controller
Enables wallet-activity subscriptions for the given accounts.
This only writes the Trigger API. Linking the device token is handled when the account is added or when notifications are enabled.
Action - When a user enables wallet activity for an account.
Parameters:
| Name | Description |
|---|---|
accounts | List of accounts to subscribe. |
Handler signature:
(accounts: string[]) => Promise<void>
NotificationServicesController:enableMetamaskNotifications
Package: @metamask/notification-services-controller
Enables all MetaMask notifications for the user. This is identical flow when initializing notifications for the first time.
Parameters:
| Name | Description |
|---|---|
opts | Optional options to mutate this functionality. |
Handler signature:
(opts?: NotificationServicesControllerEnableMetamaskNotificationsOptions) => Promise<void>
NotificationServicesController:enablePushNotifications
Package: @metamask/notification-services-controller
Public method to expose enabling push notifications
Handler signature:
() => Promise<void>
NotificationServicesController:fetchAndUpdateMetamaskNotifications
Package: @metamask/notification-services-controller
Fetches the list of metamask notifications. This includes OnChain notifications; Feature Announcements; and Snap Notifications.
Action - When a user views the notification list page/dropdown
Parameters:
| Name | Description |
|---|---|
previewToken | the preview token to use if needed |
Returns: A promise that resolves to the list of notifications.
Handler signature:
(previewToken?: string) => Promise<INotification[]>
NotificationServicesController:getNotificationsByType
Package: @metamask/notification-services-controller
Gets the specified type of notifications from state.
Parameters:
| Name | Description |
|---|---|
type | The trigger type. |
Returns: An array of notifications of the passed in type.
Handler signature:
(type: TRIGGER_TYPES) => INotification[]
NotificationServicesController:getState
Package: @metamask/notification-services-controller
Handler signature:
() => NotificationServicesControllerState
NotificationServicesController:init
Package: @metamask/notification-services-controller
Handler signature:
() => void
NotificationServicesController:markMetamaskNotificationsAsRead
Package: @metamask/notification-services-controller
Marks specified metamask notifications as read.
Parameters:
| Name | Description |
|---|---|
notifications | An array of notifications to be marked as read. Each notification should include its type and read status. |
Returns: A promise that resolves when the operation is complete.
Handler signature:
(notifications: MarkAsReadNotificationsParam) => Promise<void>
NotificationServicesController:sendPerpPlaceOrderNotification
Package: @metamask/notification-services-controller
Creates an perp order notification subscription. Requires notifications and auth to be enabled to start receiving this notifications
Parameters:
| Name | Description |
|---|---|
input | perp input |
Handler signature:
(input: OrderInput) => Promise<void>
NotificationServicesController:setFeatureAnnouncementsEnabled
Package: @metamask/notification-services-controller
Sets the enabled state of feature announcements.
Action - used in the notification settings to enable/disable feature announcements.
Parameters:
| Name | Description |
|---|---|
featureAnnouncementsEnabled | A boolean value indicating the desired enabled state of the feature announcements. |
Handler signature:
(featureAnnouncementsEnabled: boolean) => Promise<void>
NotificationServicesController:updateMetamaskNotificationsList
Package: @metamask/notification-services-controller
Updates the list of MetaMask notifications by adding a new notification at the beginning of the list. This method ensures that the most recent notification is displayed first in the UI.
Parameters:
| Name | Description |
|---|---|
notification | The new notification object to be added to the list. |
Returns: A promise that resolves when the notification list has been successfully updated.
Handler signature:
(notification: INotification) => Promise<void>