From e514d90b7a073c0d95a82703279df507d27593a9 Mon Sep 17 00:00:00 2001 From: Jude Kwashie Date: Fri, 2 Jan 2026 13:39:57 +0000 Subject: [PATCH 1/2] fix(messaging, iOS): scope iOS 18 duplicate notification workaround to iOS 18.0 only --- .../FLTFirebaseMessagingPlugin.m | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m b/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m index 8a89462afbe6..d05243f3b650 100644 --- a/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m +++ b/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m @@ -355,8 +355,18 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center // this fix) NSString *notificationIdentifier = notification.request.identifier; - if (notification.request.content.userInfo[@"gcm.message_id"] && - ![notificationIdentifier isEqualToString:_foregroundUniqueIdentifier]) { + BOOL shouldCheckForDuplicate = NO; +#if !TARGET_OS_OSX + if (@available(iOS 18.0, *)) { + if (!@available(iOS 18.1, *)) { + // Only iOS 18.0 specifically + shouldCheckForDuplicate = + [notificationIdentifier isEqualToString:_foregroundUniqueIdentifier]; + } + } +#endif + + if (notification.request.content.userInfo[@"gcm.message_id"] && !shouldCheckForDuplicate) { NSDictionary *notificationDict = [FLTFirebaseMessagingPlugin NSDictionaryFromUNNotification:notification]; [_channel invokeMethod:@"Messaging#onMessage" arguments:notificationDict]; @@ -385,7 +395,15 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center } completionHandler(presentationOptions); } - _foregroundUniqueIdentifier = notificationIdentifier; + + // Store notification identifier for iOS 18.0 duplicate detection +#if !TARGET_OS_OSX + if (@available(iOS 18.0, *)) { + if (!@available(iOS 18.1, *)) { + _foregroundUniqueIdentifier = notificationIdentifier; + } + } +#endif } // Called when a user interacts with a notification. From 4d230ea9ef520473edd9bb54221b099dae913a32 Mon Sep 17 00:00:00 2001 From: Jude Kwashie Date: Mon, 5 Jan 2026 09:59:05 +0000 Subject: [PATCH 2/2] fix(messaging, ios): use message id for iOS 18 duplicate filter --- .../firebase_messaging/FLTFirebaseMessagingPlugin.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m b/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m index d05243f3b650..3d8c9298a4e9 100644 --- a/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m +++ b/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m @@ -353,20 +353,20 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center // See this Apple issue: https://forums.developer.apple.com/forums/thread/761597 // when it has been resolved, "_foregroundUniqueIdentifier" can be removed (i.e. the commit for // this fix) - NSString *notificationIdentifier = notification.request.identifier; + NSDictionary *userInfo = notification.request.content.userInfo; + NSString *messageID = userInfo[@"gcm.message_id"]; BOOL shouldCheckForDuplicate = NO; #if !TARGET_OS_OSX if (@available(iOS 18.0, *)) { if (!@available(iOS 18.1, *)) { // Only iOS 18.0 specifically - shouldCheckForDuplicate = - [notificationIdentifier isEqualToString:_foregroundUniqueIdentifier]; + shouldCheckForDuplicate = [messageID isEqualToString:_foregroundUniqueIdentifier]; } } #endif - if (notification.request.content.userInfo[@"gcm.message_id"] && !shouldCheckForDuplicate) { + if (messageID && !shouldCheckForDuplicate) { NSDictionary *notificationDict = [FLTFirebaseMessagingPlugin NSDictionaryFromUNNotification:notification]; [_channel invokeMethod:@"Messaging#onMessage" arguments:notificationDict]; @@ -400,7 +400,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center #if !TARGET_OS_OSX if (@available(iOS 18.0, *)) { if (!@available(iOS 18.1, *)) { - _foregroundUniqueIdentifier = notificationIdentifier; + _foregroundUniqueIdentifier = messageID; } } #endif