chore: Follow up notification actions
This commit is contained in:
parent
ae11d5b47f
commit
b7e112a224
3 changed files with 20 additions and 2 deletions
|
|
@ -20,6 +20,7 @@ ReceivePort? mainIsolateReceivePort;
|
|||
void main() async {
|
||||
if (PlatformInfos.isAndroid) {
|
||||
final port = mainIsolateReceivePort = ReceivePort();
|
||||
IsolateNameServer.removePortNameMapping('main_isolate');
|
||||
IsolateNameServer.registerPortWithName(
|
||||
port.sendPort,
|
||||
'main_isolate',
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import 'package:unifiedpush/unifiedpush.dart';
|
|||
import 'package:unifiedpush_ui/unifiedpush_ui.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/main.dart';
|
||||
import 'package:fluffychat/utils/notification_background_handler.dart';
|
||||
import 'package:fluffychat/utils/push_helper.dart';
|
||||
import 'package:fluffychat/widgets/fluffy_chat_app.dart';
|
||||
|
|
@ -77,6 +78,20 @@ class BackgroundPush {
|
|||
void _init() async {
|
||||
//<GOOGLE_SERVICES>firebaseEnabled = true;
|
||||
try {
|
||||
mainIsolateReceivePort?.listen(
|
||||
(message) async {
|
||||
try {
|
||||
await notificationTap(
|
||||
NotificationResponseJson.fromJsonString(message),
|
||||
client: client,
|
||||
router: FluffyChatApp.router,
|
||||
l10n: l10n,
|
||||
);
|
||||
} catch (e, s) {
|
||||
Logs().wtf('Main Notification Tap crashed', e, s);
|
||||
}
|
||||
},
|
||||
);
|
||||
if (PlatformInfos.isAndroid) {
|
||||
final port = ReceivePort();
|
||||
IsolateNameServer.removePortNameMapping('background_tab_port');
|
||||
|
|
|
|||
|
|
@ -46,13 +46,15 @@ extension NotificationResponseJson on NotificationResponse {
|
|||
void notificationTapBackground(
|
||||
NotificationResponse notificationResponse,
|
||||
) async {
|
||||
Logs().i('Notification tap in background');
|
||||
|
||||
final sendPort = IsolateNameServer.lookupPortByName('main_isolate');
|
||||
if (sendPort != null) {
|
||||
sendPort.send(notificationResponse.toJsonString());
|
||||
Logs().i('Notification tap sent to main isolate!');
|
||||
return;
|
||||
}
|
||||
Logs().i(
|
||||
'Main isolate no up - Create temporary client for notification tap intend!',
|
||||
);
|
||||
|
||||
if (!_vodInitialized) {
|
||||
await vod.init();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue