Skip to content

Commit

Permalink
Merge pull request #2482 from acterglobal/kumar/notification-fixes
Browse files Browse the repository at this point in the history
Fixes : Chat opening twice on click of notification
  • Loading branch information
kumarpalsinh25 authored Jan 9, 2025
2 parents b9826d9 + 6f06ef5 commit 3876e70
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions .changes/2482-chat-notification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Fix] : Chat screen opening twice when tap on chat message notification issue is fixed now,
34 changes: 18 additions & 16 deletions packages/acter_notifify/lib/push.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@ Future<void> initializePush({
}) async {
try {
// Handle notification launching app from terminated state
Push.instance.notificationTapWhichLaunchedAppFromTerminated.then((data) {
if (data != null) {
_log.info('Notification tap launched app from terminated state:\n'
'RemoteMessage: $data \n');
handleMessageTap(data);
}
});

// Handle notification taps
Push.instance.onNotificationTap.listen((data) {
handleMessageTap(data);
});
//ON ANDROID: PUSH NOTIFICATION TAP IS MANAGED BY LOCAL PUSH NOTIFICATION TAP EVENT
if (!Platform.isAndroid) {
Push.instance.notificationTapWhichLaunchedAppFromTerminated.then((data) {
if (data != null) {
_log.info('Notification tap launched app from terminated state:\n'
'RemoteMessage: $data \n');
handleMessageTap(data);
}
});

// Handle notification taps
Push.instance.onNotificationTap.listen((data) {
handleMessageTap(data);
});
}

// Handle push notifications
Push.instance.addOnMessage((message) async {
Expand Down Expand Up @@ -68,7 +72,7 @@ Future<void> initializePush({
// FIXME: how to identify which clients are connected to this?
_log.info('Just got a new FCM registration token: $token');
final clients =
currentClientsGen == null ? [] : await currentClientsGen();
currentClientsGen == null ? [] : await currentClientsGen();
for (final client in clients) {
final deviceId = client.deviceId().toString();
try {
Expand All @@ -89,8 +93,7 @@ Future<void> initializePush({
}
}

Future<bool> _handlePushMessage(
RemoteMessage message, {
Future<bool> _handlePushMessage(RemoteMessage message, {
bool background = false,
ShouldShowCheck? shouldShowCheck,
}) async {
Expand All @@ -102,8 +105,7 @@ Future<bool> _handlePushMessage(
background: background, shouldShowCheck: shouldShowCheck);
}

Future<bool?> setupPushNotificationsForDevice(
Client client, {
Future<bool?> setupPushNotificationsForDevice(Client client, {
required String appName,
required String appIdPrefix,
required String pushServerUrl,
Expand Down

0 comments on commit 3876e70

Please sign in to comment.