Skip to content

feat: Finish push token registration with backend - #873

Open
dominiccreates wants to merge 2 commits into
Pulsefy:mainfrom
dominiccreates:feature/push-token-registration
Open

feat: Finish push token registration with backend#873
dominiccreates wants to merge 2 commits into
Pulsefy:mainfrom
dominiccreates:feature/push-token-registration

Conversation

@dominiccreates

Copy link
Copy Markdown
Contributor

Closes #745
This PR completes the push notification token registration flow by syncing Expo tokens from the mobile app with the backend. It also ensures tokens are reliably refreshed and cleanly revoked upon user sign-out, while also surfacing sync errors in the mobile app settings.

Changes Made
Frontend (Mobile):

New Service: Added deviceTokenApi.ts to manage syncing with the backend /device-tokens and /device-tokens/revoke-by-token endpoints. It automatically attaches the wallet publicKey via the x-user-id header for authentication.
Auto-Sync: Updated NotificationContext.tsx to automatically call syncToken whenever push notification permissions are granted and a new Expo push token is acquired.
Sign-Out Flow: Updated WalletContext.tsx to automatically call revokeToken when a user disconnects their wallet, ensuring the token is invalidated on the backend.
Error Visibility: Updated SettingsScreen.tsx to render a visible error banner beneath the notifications section if a token fails to sync with the backend.
Backend:

New Endpoint: Added a POST /device-tokens/revoke-by-token endpoint for mobile clients to easily revoke tokens without needing the internal database ID.
Mobile Auth: Added the @public() decorator to /device-tokens routes to bypass strict API key enforcement, and updated the controller to accept the user's wallet public key via the x-user-id header when identifying the actor.
Testing/Verification
Registration: Open the mobile app and grant push notification permissions. Verify that a new record is created in the backend DeviceNotificationToken table containing the wallet publicKey as the userId.
Sign-Out: Disconnect the wallet in the app. Verify that the token record is marked as revoked (isActive: false and revokedAt is populated) in the database.
Error Handling: Simulate a network failure or backend error and verify that the red sync error banner appears on the Settings screen.
1:04 PM

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@dominiccreates Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Cedarich Cedarich left a comment

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.

Kindly fix failed CI

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.

Finish Push Token Registration With Backend

2 participants