Is your feature request related to a problem?
The PushTokenManager skeleton class exists in packages/notifications_kit/lib/push/push_token_manager.dart but needs full implementation to manage FCM device tokens, handle token refresh, sync with backend, and track token registration state.
Describe the solution you'd like
Implement a fully functional PushTokenManager service that retrieves FCM tokens, monitors token refresh, syncs tokens with backend API, and manages token storage with proper error handling.
What is PushTokenManager and why do we need it?
PushTokenManager is a service that manages Firebase Cloud Messaging device tokens, ensuring the backend has the current token for sending push notifications and handling token refresh scenarios.
Why it's important:
- Backend Sync: Backend needs current token to send notifications
- Token Refresh: FCM tokens can change and need re-syncing
- Reliability: Ensures notifications always reach the device
- Multi-Device: Tracks tokens per user across devices
- Debugging: Helps troubleshoot notification delivery issues
Common use cases:
- Initial token retrieval on app start
- Token refresh handling
- Syncing token with backend on login
- Removing token from backend on logout
- Multi-device token management
- Token debugging and logging
Required Deliverables
-
PushTokenManager implementation with:
- Get current FCM token
- Monitor token refresh
- Sync token with backend API
- Remove token from backend
- Store token locally
- Token refresh stream
- Error handling and retry
- Integration with AuthService
- Integration with ApiClient
-
Widgetbook stories (6-8 use cases):
- Get token demo
- Token refresh handling
- Sync with backend
- Token storage
- Remove token on logout
- Error handling
- Token inspector UI
- Multi-device token display
-
SPDX headers in all source files
Key Implementation Specs
- getToken() returns Future<String?>
- refreshToken() forces token refresh
- syncWithBackend() sends token to API
- removeToken() deletes token from backend
- tokenRefreshStream returns Stream
- Store token in local storage
- API endpoint: POST /api/device-tokens
- Retry logic for sync failures
- Integration with AuthService (user ID)
- Integration with ApiClient
Acceptance Criteria
Related Files
packages/notifications_kit/lib/push/push_token_manager.dart (skeleton)
packages/notifications_kit/lib/push/push_notification_service.dart (uses manager)
packages/auth_kit/lib/services/auth_service.dart (user context)
packages/data_kit/lib/http/api_client.dart (backend sync)
widgetbook_kit/lib/stories/notifications_kit/push_token_manager_story.dart (Widgetbook)
Impact: Critical for push notification delivery; ensures backend has current tokens
Priority: High
Is your feature request related to a problem?
The
PushTokenManagerskeleton class exists inpackages/notifications_kit/lib/push/push_token_manager.dartbut needs full implementation to manage FCM device tokens, handle token refresh, sync with backend, and track token registration state.Describe the solution you'd like
Implement a fully functional
PushTokenManagerservice that retrieves FCM tokens, monitors token refresh, syncs tokens with backend API, and manages token storage with proper error handling.What is PushTokenManager and why do we need it?
PushTokenManager is a service that manages Firebase Cloud Messaging device tokens, ensuring the backend has the current token for sending push notifications and handling token refresh scenarios.
Why it's important:
Common use cases:
Required Deliverables
PushTokenManager implementation with:
Widgetbook stories (6-8 use cases):
SPDX headers in all source files
Key Implementation Specs
Acceptance Criteria
Related Files
packages/notifications_kit/lib/push/push_token_manager.dart(skeleton)packages/notifications_kit/lib/push/push_notification_service.dart(uses manager)packages/auth_kit/lib/services/auth_service.dart(user context)packages/data_kit/lib/http/api_client.dart(backend sync)widgetbook_kit/lib/stories/notifications_kit/push_token_manager_story.dart(Widgetbook)Impact: Critical for push notification delivery; ensures backend has current tokens
Priority: High