feat(notifications): register FCM token with backend post-login

Adds NotificationsRemoteDatasource in sf_shared that POSTs the current
Firebase Messaging token to /notifications/push, wired into the legacy
login flow right after getUserInfo so the device can receive targeted
push notifications.

Fire-and-forget with catchError so a failure never blocks login.
This commit is contained in:
2026-04-08 15:40:37 +02:00
parent 60558a4fcf
commit d352aec5be
7 changed files with 62 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ class LegacyLoginViewModel extends Notifier<LegacyLoginViewState>
with LoginFormValidation {
late final LegacyLoginRepository _repository;
late final GetUserInfoUseCase _getUserInfoUseCase;
late final NotificationsRemoteDatasource _notifications;
late final SfTrackingRepository _tracking;
late final TextEditingController emailController;
@@ -32,6 +33,7 @@ class LegacyLoginViewModel extends Notifier<LegacyLoginViewState>
LegacyLoginViewState build() {
_repository = ref.read(legacyLoginRepositoryProvider);
_getUserInfoUseCase = ref.read(getUserInfoUseCaseProvider);
_notifications = ref.read(notificationsRemoteDatasourceProvider);
_tracking = ref.read(sfTrackingProvider);
emailController = TextEditingController();
@@ -224,6 +226,12 @@ class LegacyLoginViewModel extends Notifier<LegacyLoginViewState>
if (!ref.mounted) return;
unawaited(
_notifications.registerCurrentPushToken().catchError((Object e) {
debugPrint('[FCM] failed to register push token post-login: $e');
}),
);
final hasDevices = await _repository.hasDevices();
if (!ref.mounted) return;

File diff suppressed because one or more lines are too long