From 6cc2ad3a6549132b3fcc2c54978a00c44ec46252 Mon Sep 17 00:00:00 2001 From: otsmr Date: Sun, 5 Apr 2026 21:50:31 +0200 Subject: [PATCH] fix logging issue for background execution --- .../background/callback_dispatcher.background.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/services/background/callback_dispatcher.background.dart b/lib/src/services/background/callback_dispatcher.background.dart index 94980df..0286c11 100644 --- a/lib/src/services/background/callback_dispatcher.background.dart +++ b/lib/src/services/background/callback_dispatcher.background.dart @@ -49,7 +49,18 @@ void callbackDispatcher() { }); } +bool _isInitialized = false; + Future initBackgroundExecution() async { + if (_isInitialized) { + // Reload the users, as on Android the background isolate can + // stay alive for multiple hours between task executions + final user = await getUser(); + if (user == null) return false; + gUser = user; + return true; + } + SentryWidgetsFlutterBinding.ensureInitialized(); globalApplicationCacheDirectory = (await getApplicationCacheDirectory()).path; globalApplicationSupportDirectory = @@ -65,6 +76,7 @@ Future initBackgroundExecution() async { apiService = ApiService(); globalIsInBackgroundTask = true; + _isInitialized = true; return true; }