Skip to content

Commit 4d230ea

Browse files
committed
fix(messaging, ios): use message id for iOS 18 duplicate filter
1 parent e514d90 commit 4d230ea

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,20 +353,20 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
353353
// See this Apple issue: https://forums.developer.apple.com/forums/thread/761597
354354
// when it has been resolved, "_foregroundUniqueIdentifier" can be removed (i.e. the commit for
355355
// this fix)
356-
NSString *notificationIdentifier = notification.request.identifier;
356+
NSDictionary *userInfo = notification.request.content.userInfo;
357+
NSString *messageID = userInfo[@"gcm.message_id"];
357358

358359
BOOL shouldCheckForDuplicate = NO;
359360
#if !TARGET_OS_OSX
360361
if (@available(iOS 18.0, *)) {
361362
if (!@available(iOS 18.1, *)) {
362363
// Only iOS 18.0 specifically
363-
shouldCheckForDuplicate =
364-
[notificationIdentifier isEqualToString:_foregroundUniqueIdentifier];
364+
shouldCheckForDuplicate = [messageID isEqualToString:_foregroundUniqueIdentifier];
365365
}
366366
}
367367
#endif
368368

369-
if (notification.request.content.userInfo[@"gcm.message_id"] && !shouldCheckForDuplicate) {
369+
if (messageID && !shouldCheckForDuplicate) {
370370
NSDictionary *notificationDict =
371371
[FLTFirebaseMessagingPlugin NSDictionaryFromUNNotification:notification];
372372
[_channel invokeMethod:@"Messaging#onMessage" arguments:notificationDict];
@@ -400,7 +400,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
400400
#if !TARGET_OS_OSX
401401
if (@available(iOS 18.0, *)) {
402402
if (!@available(iOS 18.1, *)) {
403-
_foregroundUniqueIdentifier = notificationIdentifier;
403+
_foregroundUniqueIdentifier = messageID;
404404
}
405405
}
406406
#endif

0 commit comments

Comments
 (0)