migrated custom timetable events to Marianum-Connect and refactored push notification handling

This commit is contained in:
2026-07-12 14:31:48 +02:00
parent c444ed54a5
commit 91a6216f66
28 changed files with 474 additions and 212 deletions
+13 -12
View File
@@ -178,22 +178,23 @@ class _AppState extends State<App> with WidgetsBindingObserver {
if (mounted) setState(() {});
});
TelemetryHeartbeat.report();
TelemetryHeartbeat.report(
notificationsEnabled:
context.read<SettingsCubit>().val().notificationSettings.enabled,
);
// A refreshed FCM token invalidates the existing push subscription — the
// NC device identifier stays stable, so we simply re-register (NC first,
// then the proxy). Debounced so a burst of refreshes triggers one call.
if (context.read<SettingsCubit>().val().notificationSettings.enabled) {
_fcmTokenRefreshSub = FirebaseMessaging.instance.onTokenRefresh.listen((
_,
) {
Debouncer.debounce(
'pushTokenRefresh',
const Duration(seconds: 3),
() => unawaited(PushRegistration().onTokenRefresh()),
);
});
}
// Not gated on the notification toggle: registration is kept alive even
// when notifications are off so silent sync pushes keep flowing.
_fcmTokenRefreshSub = FirebaseMessaging.instance.onTokenRefresh.listen((_) {
Debouncer.debounce(
'pushTokenRefresh',
const Duration(seconds: 3),
() => unawaited(PushRegistration().onTokenRefresh()),
);
});
// Android renders pushes locally, so a tap arrives via the local
// notifications callback (PushTapRouter) rather than onMessageOpenedApp.