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