fix(app): say it out loud when wake-ups do not work

Registration failures from the distributor were swallowed, so push looked
enabled while nothing arrived. Without wake-ups Android suspends the app
and messages only show up once the user opens it — which looks like broken
delivery even though the relay has them queued.

The failure is now remembered and surfaced in Settings, and the chat list
carries a dismissible line explaining the state.
This commit is contained in:
Julius Joska
2026-08-13 12:23:30 +02:00
parent 9985b79aa6
commit 923a6a01bd
18 changed files with 305 additions and 10 deletions
+14 -1
View File
@@ -45,6 +45,7 @@ class PushBootstrap {
static const _pendingEndpointKey = 'pending_push_endpoint';
static const _modeKey = 'push_mode'; // 'off' | 'up' | 'fcm'
static const _registrationFailedKey = 'push_registration_failed';
static const _store = FlutterSecureStorage(
aOptions: AndroidOptions(encryptedSharedPreferences: true),
);
@@ -57,6 +58,16 @@ class PushBootstrap {
static Future<void> writeMode(String mode) =>
_store.write(key: _modeKey, value: mode);
/// Odmítl distributor registraci? Selhání se dřív jen spolklo, takže
/// uživatel měl v Nastavení „push zapnutý", ale budíčky nechodily a
/// zprávy čekaly, než appku otevře. Nastavení si to přečte a řekne to.
static Future<bool> registrationFailed() async =>
await _store.read(key: _registrationFailedKey) == '1';
static Future<void> _setRegistrationFailed(bool failed) => failed
? _store.write(key: _registrationFailedKey, value: '1')
: _store.delete(key: _registrationFailedKey);
static Future<void> init(List<String> args) async {
backgroundStart = args.contains('--unifiedpush-bg');
@@ -69,7 +80,8 @@ class PushBootstrap {
} else {
await UnifiedPush.initialize(
onNewEndpoint: _onNewEndpoint,
onRegistrationFailed: (_, _) {},
onRegistrationFailed: (_, _) =>
unawaited(_setRegistrationFailed(true)),
onUnregistered: _onUnregistered,
onMessage: _onMessage,
);
@@ -114,6 +126,7 @@ class PushBootstrap {
}
static void _onNewEndpoint(PushEndpoint endpoint, String instance) {
unawaited(_setRegistrationFailed(false)); // registrace se povedla
final s = _service;
if (s != null) {
s.handleNewEndpoint(endpoint.url);