From 6f9b08e8447ab075a0d565f865cd128b8f84a201 Mon Sep 17 00:00:00 2001 From: Julius Joska Date: Sun, 11 Oct 2026 16:12:41 +0200 Subject: [PATCH] fix(push): do not call UnifiedPush outside Android UnifiedPush only exists on Android. On iOS getDistributor() and getDistributors() throw UnimplementedError, which surfaced as an uncaught error from the Push tile in Settings. Report an empty state instead. --- app/lib/core/push/push_service.dart | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/lib/core/push/push_service.dart b/app/lib/core/push/push_service.dart index 9ef27a9..7ded2b8 100644 --- a/app/lib/core/push/push_service.dart +++ b/app/lib/core/push/push_service.dart @@ -138,10 +138,14 @@ class PushService { } /// Seznam nainstalovaných distributorů (pro výběr v nastavení). - Future> distributors() => UnifiedPush.getDistributors(); + /// UnifiedPush existuje jen na Androidu; jinde by volání pluginu vyhodilo + /// UnimplementedError (iOS: dlaždice Push v Nastavení). + Future> distributors() async => + Platform.isAndroid ? UnifiedPush.getDistributors() : const []; /// Aktuálně uložený distributor (null = push vypnutý / nevybraný). - Future currentDistributor() => UnifiedPush.getDistributor(); + Future currentDistributor() async => + Platform.isAndroid ? UnifiedPush.getDistributor() : null; /// Vybere konkrétního distributora a zaregistruje se u něj. Future useDistributor(String distributor) async { @@ -158,7 +162,7 @@ class PushService { } Future get isEnabled async => - (await UnifiedPush.getDistributor()) != null; + Platform.isAndroid && (await UnifiedPush.getDistributor()) != null; // ── Režimy (off / up / fcm) ───────────────────────────────────────── @@ -167,6 +171,7 @@ class PushService { Future currentMode() async { final mode = await PushBootstrap.readMode(); if (mode != 'off') return mode; + if (!Platform.isAndroid) return mode; return (await UnifiedPush.getDistributor()) != null ? 'up' : 'off'; }