Skip to content

Commit

Permalink
Revert "refactor: Do not init client in background mode on Android"
Browse files Browse the repository at this point in the history
This reverts commit 3cea32e.
  • Loading branch information
krille-chan committed Nov 4, 2023
1 parent 3cea32e commit 1789211
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,15 @@ void main() async {
// widget bindings are initialized already.
WidgetsFlutterBinding.ensureInitialized();

final backgroundMode = PlatformInfos.isAndroid &&
AppLifecycleState.detached == WidgetsBinding.instance.lifecycleState;
Logs().nativeColors = !PlatformInfos.isIOS;
final store = await SharedPreferences.getInstance();
final clients = await ClientManager.getClients(
store: store,
initialize: !backgroundMode,
);
final clients = await ClientManager.getClients(store: store);

// If the app starts in detached mode, we assume that it is in
// background fetch mode for processing push notifications. This is
// currently only supported on Android.
if (backgroundMode) {
if (PlatformInfos.isAndroid &&
AppLifecycleState.detached == WidgetsBinding.instance.lifecycleState) {
// 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

0 comments on commit 1789211

Please sign in to comment.