Skip to content

fix: link existing push token when notification accounts are added - #8449

Merged
oilnam merged 3 commits into
mainfrom
feat/notify-push-tokens
Apr 14, 2026
Merged

oilnam merged 3 commits into
mainfrom
feat/notify-push-tokens

Conversation

@oilnam

@oilnam oilnam commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

Summary

When notification accounts are added after push notifications have already been enabled, we were updating on-chain triggers, but not re-linking the existing Firebase token to the newly added addresses. As a result, the backend never received the additive POST /api/v2/token call for those new (address, token) pairs.

This change adds a dedicated additive push-link path that reuses the current fcmToken and links only the newly added
addresses, without rotating the token or sending oldToken.
Because notification account discovery already includes all keyrings, this now covers:

  • adding accounts on the primary SRP
  • adding accounts on imported/subsequent SRPs

Code Changes

  • Add NotificationServicesPushController:addPushNotificationLinks
  • Use the existing fcmToken to POST newly added addresses to the push registration endpoint
  • Call that new method from NotificationServicesController.enableAccounts(...) after on-chain notifications are enabled
  • Add focused tests for both the controller flow and the push-controller API call
  • Update the package changelog

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Updates push-notification registration flow to add backend token links when accounts are enabled, affecting server-side delivery for newly added addresses. Risk is moderate due to changes in notification subscription side effects and new messenger action surface, but behavior is guarded and tested.

Overview
Fixes a gap where enabling notifications for newly added accounts updated on-chain triggers but did not register the existing device push token for those addresses.

Adds NotificationServicesPushController:addPushNotificationLinks (with exported action type) to POST additive (address, token) links using the current fcmToken, and wires NotificationServicesController.enableAccounts() to invoke it after enabling on-chain notifications (silent-fail like other push calls). Tests are updated to cover the new controller call and the push-controller API call/guard conditions, and the changelog documents the fix.

Reviewed by Cursor Bugbot for commit 7a8eae8. Bugbot is set up for automated code reviews on this repo. Configure here.

@oilnam
oilnam requested review from a team as code owners April 14, 2026 10:07

### Fixed

- Add backend push token links for newly added notification accounts using the existing device token, so account additions trigger additive `POST /api/v2/token` registration for both primary and imported SRPs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Add GH link to this changelog.
  2. Might also be worth expanding a little on some additions (so that way humans/AI can read changelog and correctly update clients. -- E.g. new "allowedActions" addition.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6aa3ae5. Configure here.

Comment thread packages/notification-services-controller/CHANGELOG.md Outdated
@oilnam
oilnam added this pull request to the merge queue Apr 14, 2026
Merged via the queue into main with commit 6dc536e Apr 14, 2026
341 checks passed
@oilnam
oilnam deleted the feat/notify-push-tokens branch April 14, 2026 12:37
- Bump `@metamask/controller-utils` from `^11.19.0` to `^11.20.0` ([#8344](https://github.com/MetaMask/core/pull/8344))
- Bump `@metamask/messenger` from `^1.0.0` to `^1.1.1` ([#8364](https://github.com/MetaMask/core/pull/8364), [#8373](https://github.com/MetaMask/core/pull/8373))

### Fixed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Prithpal-Sooriya this should have been added under Added

github-merge-queue Bot pushed a commit to MetaMask/metamask-extension that referenced this pull request Apr 16, 2026
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

This updates the extension notifications settings page so account
activity toggles are shown for all notification-eligible accounts across
all wallets/keyrings, instead of effectively being limited to the first
SRP flow.

This builds on the core changes in MetaMask/core#8108, where
notification account discovery was expanded beyond the first keyring to
include all supported EVM accounts. The extension now reflects that
broader account set in the UI by grouping notification toggles by wallet
and preserving the existing per-account enable/disable behavior.

Further adjustments to the core changes were merged in
MetaMask/core#8449

Example with accounts from `Wallet 1` (outside screenshot), accounts
from `Wallet 2`, and a manually imported account from the `Notifications
Settings` page:

<img width="531" height="575" alt="image"
src="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/user-attachments/assets/11b1d60b-74ff-4503-80cf-21e70fb0ca42"
/>


[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/40762?quickstart=1)

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: Extend notification account toggles to all wallet
keyrings

## **Related issues**

Fixes:

## **Manual testing steps**

  1. Open Notifications Settings with notifications enabled.
2. Verify account activity toggles are shown under each wallet section
for eligible accounts across multiple wallets/keyrings.
  3. Verify non-EVM accounts are not shown.
4. Toggle an account notification setting and confirm the existing
behavior still works.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Bumps `@metamask/notification-services-controller` and updates
messenger allowlists/LavaMoat policies, which could affect notification
subscription/linking and bundling behavior if mismatched with runtime
expectations.
> 
> **Overview**
> Updates Notifications Settings to show per-account notification
toggles **grouped by wallet/keyring**, using multichain account groups
and filtering to notification-eligible EVM addresses; the per-account
enable/disable behavior is preserved while the section is hidden when no
eligible accounts exist.
> 
> Adds `getNotificationWalletGroups` with unit tests plus a new
`NotificationsSettingsContent` render test for grouped output. Expands
the notifications controller messenger delegation to include push link
add/delete actions, updates a rate-limit messenger type import, and
bumps `@metamask/notification-services-controller` to `^23.1.0` with
corresponding LavaMoat policy updates (notably adding `lodash`).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
d2c65a8. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Baptiste Marchand <75846779+baptiste-marchand@users.noreply.github.com>
pull Bot pushed a commit to Pe44e/metamask-mobile that referenced this pull request Apr 21, 2026
…aMask#27254)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
Update **Notifications settings** so the **Account activity** section
lists notification-eligible accounts from all wallet keyrings, not just
the first HD wallet. This is tied to the relevant PRs in MM-core:
- MetaMask/core#8108
- MetaMask/core#8449

Keep the existing per-account toggle behavior unchanged, so imported
accounts use the same enable/disable notification flow as HD accounts.

Add focused test coverage for multi-wallet rendering and update the
settings snapshot accordingly.
 
<img width="328" height="722" alt="image"
src="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/user-attachments/assets/b2c296a2-2cb7-4087-b33f-84741a90c3fb"
/>


## **Changelog**


<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: Extend notification account toggles to all wallet
keyrings

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]
```

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.



<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes the account-listing/filtering logic in notification settings
and upgrades the notification services controller, which could affect
which accounts appear and push-link behavior if filtering/messenger
wiring is incorrect.
> 
> **Overview**
> Extends **Notification Settings → Account activity** to list
notification-eligible (EVM) accounts across *all* wallets/keyrings,
instead of only the first HD/entropy wallet.
> 
> Introduces `useNotificationWalletAccountGroups()` to filter
wallet/account groups down to those containing EVM accounts, updates
`AccountsList` to render per-wallet sections via `SectionList` (skipping
non-EVM groups), and adjusts the settings screen to show/hide the
section based on these filtered groups. Updates and expands unit/UI
tests to cover multi-wallet rendering and empty/no-EVM scenarios, and
refreshes smoke-test notification mocks.
> 
> Also updates the notifications controller messenger delegation to
include push link add/delete actions, and bumps
`@metamask/notification-services-controller` to `^23.1.0`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9844b6e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
pull Bot pushed a commit to Reality2byte/core that referenced this pull request Sep 24, 2026
## Explanation

Toggling wallet activity for an account was also adding or deleting that
address's FCM token link. Those links are not scoped to wallet activity:
they associate the device token with an address for every notification
source. Turning wallet activity off therefore stopped push for the other
sources as well.

`enableAccounts` and `disableAccounts` now write only the Trigger API,
which is the wallet-activity subscription. FCM links follow the
addresses this installation holds:

- Adding an account links the existing token, and removing an account
unlinks it. This still runs only while the main notifications toggle is
on.
- Enabling notifications, including the daily refresh, registers the
token for every keyring address. A wallet-activity opt-out stays linked,
so other sources keep working, and the next unlock restores links that
an older client deleted.

No client change is required. The public method signatures are
unchanged.

## References

* Related to MetaMask#10401
* Related to MetaMask#8108
* Related to MetaMask#8449

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them


Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants