push registration no longer depends on notification permission, reporting effective opt-in and os permission

This commit is contained in:
2026-09-26 23:38:24 +02:00
parent e6f74ca6fe
commit 2aed3d104c
6 changed files with 129 additions and 81 deletions
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../api/marianumconnect/queries/telemetry_heartbeat/telemetry_heartbeat.dart';
import '../../../../push/push_registration.dart';
import '../../../../push/push_status.dart';
import '../../../../routing/app_routes.dart';
@@ -123,6 +124,8 @@ class _PushSettingsState extends State<_PushSettings>
void _onToggle(bool enabled) {
widget.settings.val(write: true).notificationSettings.enabled = enabled;
// A permission granted below arrives via the resume heartbeat.
TelemetryHeartbeat.report(notificationsEnabled: enabled);
// Turning off does NOT unregister: the device stays subscribed so silent
// sync pushes keep arriving; the message handler and iOS NSE suppress only
// the visible notification (via the mirrored flag). Enabling (re-)registers
@@ -132,11 +135,10 @@ class _PushSettingsState extends State<_PushSettings>
final messenger = ScaffoldMessenger.of(context);
unawaited(() async {
try {
// Only register when the OS permission isn't explicitly denied —
// otherwise NC + proxy would push into the void.
if (await PushRegistration.requestOsPermission()) {
await PushRegistration().register();
} else {
final granted = await PushRegistration.requestOsPermission();
// Registered regardless: silent sync pushes need no permission.
await PushRegistration().register();
if (!granted) {
messenger.showSnackBar(
const SnackBar(
content: Text(