mirror of
https://github.com/krille-chan/fluffychat
synced 2024-08-11 11:13:54 +00:00
refactor: Do not init client in background mode on Android
This might make push notifications even faster on android
This commit is contained in:
parent
1e4147e31c
commit
3cea32e1c8
1 changed files with 7 additions and 3 deletions
|
@ -21,15 +21,19 @@ 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);
|
||||
final clients = await ClientManager.getClients(
|
||||
store: store,
|
||||
initialize: !backgroundMode,
|
||||
);
|
||||
|
||||
// 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 (PlatformInfos.isAndroid &&
|
||||
AppLifecycleState.detached == WidgetsBinding.instance.lifecycleState) {
|
||||
if (backgroundMode) {
|
||||
// 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);
|
||||
|
|
Loading…
Reference in a new issue