feat: iOS from receiving triple notificaitons to double only

This commit is contained in:
sBubshait 2025-08-07 11:53:17 +03:00
parent 75e12db502
commit bad06d34f4

View File

@ -163,10 +163,11 @@ class NotificationService {
}
void _showNotification(RemoteNotification notification) {
// For web, we rely on the service worker to show notifications
// This is mainly for logging and debugging
print('Notification Title: ${notification.title}');
print('Notification Body: ${notification.body}');
// For web PWA, we rely on the service worker to show notifications
// This method is only for logging since service worker handles the UI
print('Foreground notification received - Title: ${notification.title}');
print('Foreground notification received - Body: ${notification.body}');
// Note: Do not show browser notification here as service worker handles it
}
void _handleNotificationTap(RemoteMessage message) {
@ -307,12 +308,15 @@ class NotificationService {
final payload = {
'message': {
'token': token,
'notification': {'title': title, 'body': body},
'data': data ?? {},
// Use data-only for PWA to prevent duplicate notifications
'data': {
'title': title,
'body': body,
...(data ?? {}),
},
'webpush': {
'notification': {
'icon': 'icons/ios/192.png',
'badge': 'icons/ios/192.png',
'headers': {
'Urgency': 'normal',
},
},
},
@ -366,12 +370,15 @@ class NotificationService {
final payload = {
'message': {
'topic': topic,
'notification': {'title': title, 'body': body},
'data': data ?? {},
// Use data-only for PWA to prevent duplicate notifications
'data': {
'title': title,
'body': body,
...(data ?? {}),
},
'webpush': {
'notification': {
'icon': 'icons/ios/192.png',
'badge': 'icons/ios/192.png',
'headers': {
'Urgency': 'normal',
},
},
},