migrated custom timetable events to Marianum-Connect and refactored push notification handling
This commit is contained in:
@@ -350,21 +350,26 @@ class PushRegistration {
|
||||
}
|
||||
}
|
||||
|
||||
/// Registers this device when push is both user-enabled and backend-capable.
|
||||
/// Only registers when the OS notification permission is *already* granted —
|
||||
/// it never triggers the OS prompt itself. Requesting the permission is the
|
||||
/// job of the first Talk visit (see `maybePromptTalkNotifications`), which
|
||||
/// keeps the prompt out of the cold-start path. Safe to call on every start —
|
||||
/// Nextcloud dedups an unchanged registration — which also self-heals a
|
||||
/// device whose registration was lost.
|
||||
static Future<void> syncSubscription({
|
||||
required bool enabled,
|
||||
required bool capable,
|
||||
}) async {
|
||||
if (!(enabled && capable)) return;
|
||||
/// Registers this device whenever the backend advertises the push capability.
|
||||
/// Deliberately independent of the in-app notification toggle: a user who
|
||||
/// turned notifications off stays registered so silent sync pushes keep
|
||||
/// flowing — the display is suppressed downstream via the mirrored flag (see
|
||||
/// [PushRegistrationStore.notificationsEnabled]). Only registers when the OS
|
||||
/// notification permission is *already* granted — it never triggers the OS
|
||||
/// prompt itself. Requesting the permission is the job of the first Talk visit
|
||||
/// (see `maybePromptTalkNotifications`), which keeps the prompt out of the
|
||||
/// cold-start path. Safe to call on every start — Nextcloud dedups an
|
||||
/// unchanged registration — which also self-heals a device whose registration
|
||||
/// was lost.
|
||||
/// Returns whether registration was actually *attempted* (all gates passed).
|
||||
/// Even a partial success persists the `general` device identifier, so the
|
||||
/// caller re-emits telemetry on `true` to reflect the fresh registration in
|
||||
/// the same session instead of lagging until the next launch.
|
||||
static Future<bool> syncSubscription({required bool capable}) async {
|
||||
if (!capable) return false;
|
||||
if (!await isOsPermissionGranted()) {
|
||||
log('Push: OS notification permission not granted, skipping registration');
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
final registration = PushRegistration();
|
||||
// register() below refreshes an unchanged subscription anyway; the check
|
||||
@@ -373,6 +378,7 @@ class PushRegistration {
|
||||
log('Push: registered endpoints outdated, re-registering');
|
||||
}
|
||||
await registration.register();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Re-registers after an FCM token refresh. The Nextcloud device identifier
|
||||
|
||||
Reference in New Issue
Block a user