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 {
|
void main() async {
|
||||||
if (PlatformInfos.isAndroid) {
|
if (PlatformInfos.isAndroid) {
|
||||||
final port = mainIsolateReceivePort = ReceivePort();
|
final port = mainIsolateReceivePort = ReceivePort();
|
||||||
|
IsolateNameServer.removePortNameMapping('main_isolate');
|
||||||
IsolateNameServer.registerPortWithName(
|
IsolateNameServer.registerPortWithName(
|
||||||
port.sendPort,
|
port.sendPort,
|
||||||
'main_isolate',
|
'main_isolate',
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import 'package:unifiedpush/unifiedpush.dart';
|
||||||
import 'package:unifiedpush_ui/unifiedpush_ui.dart';
|
import 'package:unifiedpush_ui/unifiedpush_ui.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/l10n/l10n.dart';
|
import 'package:fluffychat/l10n/l10n.dart';
|
||||||
|
import 'package:fluffychat/main.dart';
|
||||||
import 'package:fluffychat/utils/notification_background_handler.dart';
|
import 'package:fluffychat/utils/notification_background_handler.dart';
|
||||||
import 'package:fluffychat/utils/push_helper.dart';
|
import 'package:fluffychat/utils/push_helper.dart';
|
||||||
import 'package:fluffychat/widgets/fluffy_chat_app.dart';
|
import 'package:fluffychat/widgets/fluffy_chat_app.dart';
|
||||||
|
|
@ -77,6 +78,20 @@ class BackgroundPush {
|
||||||
void _init() async {
|
void _init() async {
|
||||||
//<GOOGLE_SERVICES>firebaseEnabled = true;
|
//<GOOGLE_SERVICES>firebaseEnabled = true;
|
||||||
try {
|
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) {
|
if (PlatformInfos.isAndroid) {
|
||||||
final port = ReceivePort();
|
final port = ReceivePort();
|
||||||
IsolateNameServer.removePortNameMapping('background_tab_port');
|
IsolateNameServer.removePortNameMapping('background_tab_port');
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,15 @@ extension NotificationResponseJson on NotificationResponse {
|
||||||
void notificationTapBackground(
|
void notificationTapBackground(
|
||||||
NotificationResponse notificationResponse,
|
NotificationResponse notificationResponse,
|
||||||
) async {
|
) async {
|
||||||
Logs().i('Notification tap in background');
|
|
||||||
|
|
||||||
final sendPort = IsolateNameServer.lookupPortByName('main_isolate');
|
final sendPort = IsolateNameServer.lookupPortByName('main_isolate');
|
||||||
if (sendPort != null) {
|
if (sendPort != null) {
|
||||||
sendPort.send(notificationResponse.toJsonString());
|
sendPort.send(notificationResponse.toJsonString());
|
||||||
|
Logs().i('Notification tap sent to main isolate!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Logs().i(
|
||||||
|
'Main isolate no up - Create temporary client for notification tap intend!',
|
||||||
|
);
|
||||||
|
|
||||||
if (!_vodInitialized) {
|
if (!_vodInitialized) {
|
||||||
await vod.init();
|
await vod.init();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue