diff --git a/lib/main.dart b/lib/main.dart index 9f9c350c2..b07e69a8e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,6 @@ +import 'dart:isolate'; +import 'dart:ui'; + import 'package:flutter/material.dart'; import 'package:collection/collection.dart'; @@ -12,12 +15,22 @@ import 'config/setting_keys.dart'; import 'utils/background_push.dart'; import 'widgets/fluffy_chat_app.dart'; +ReceivePort? mainIsolateReceivePort; + void main() async { // Our background push shared isolate accesses flutter-internal things very early in the startup proccess // To make sure that the parts of flutter needed are started up already, we need to ensure that the // widget bindings are initialized already. WidgetsFlutterBinding.ensureInitialized(); + if (PlatformInfos.isAndroid) { + final port = mainIsolateReceivePort = ReceivePort(); + IsolateNameServer.registerPortWithName( + port.sendPort, + 'main_isolate', + ); + } + final store = await AppSettings.init(); Logs().i('Welcome to ${AppSettings.applicationName.value} <3'); diff --git a/lib/utils/notification_background_handler.dart b/lib/utils/notification_background_handler.dart index aa8ea17dd..32113502a 100644 --- a/lib/utils/notification_background_handler.dart +++ b/lib/utils/notification_background_handler.dart @@ -48,7 +48,7 @@ void notificationTapBackground( ) async { Logs().i('Notification tap in background'); - final sendPort = IsolateNameServer.lookupPortByName('background_tab_port'); + final sendPort = IsolateNameServer.lookupPortByName('main_isolate'); if (sendPort != null) { sendPort.send(notificationResponse.toJsonString()); return;