Skip to content

Commit

Permalink
chore: Follow up send presences in background fetch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Nov 11, 2023
1 parent d6e5a07 commit a41dd4c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ void main() async {
// currently only supported on Android.
if (PlatformInfos.isAndroid &&
AppLifecycleState.detached == WidgetsBinding.instance.lifecycleState) {
// Do not send online presences when app is in background fetch mode.
for (final client in clients) {
client.syncPresence = PresenceType.offline;
}

// In the background fetch mode we do not want to waste ressources with
// starting the Flutter engine but process incoming push notifications.
BackgroundPush.clientOnly(clients.first);
Expand Down Expand Up @@ -87,6 +92,10 @@ class AppStarter with WidgetsBindingObserver {
Logs().i(
'${AppConfig.applicationName} switches from the detached background-fetch mode to ${state.name} mode. Rendering GUI...',
);
// Switching to foreground mode needs to reenable send online sync presence.
for (final client in clients) {
client.syncPresence = PresenceType.online;
}
startGui(clients, store);
// We must make sure that the GUI is only started once.
guiStarted = true;
Expand Down

0 comments on commit a41dd4c

Please sign in to comment.