Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ @implementation FLTFirebaseMessagingPlugin {

NSString *_initialNotificationID;
NSString *_notificationOpenedAppID;
NSString *_foregroundUniqueIdentifier;

#ifdef __FF_NOTIFICATIONS_SUPPORTED_PLATFORM
API_AVAILABLE(ios(10), macosx(10.14))
Expand Down Expand Up @@ -314,10 +315,17 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
(void (^)(UNNotificationPresentationOptions options))completionHandler
API_AVAILABLE(macos(10.14), ios(10.0)) {
// We only want to handle FCM notifications.
if (notification.request.content.userInfo[@"gcm.message_id"]) {

// FIX - bug on iOS 18 which results in duplicate foreground notifications posted
// 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;

if (notification.request.content.userInfo[@"gcm.message_id"] &&
![notificationIdentifier isEqualToString:_foregroundUniqueIdentifier]) {
NSDictionary *notificationDict =
[FLTFirebaseMessagingPlugin NSDictionaryFromUNNotification:notification];

[_channel invokeMethod:@"Messaging#onMessage" arguments:notificationDict];
}

Expand All @@ -344,6 +352,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
}
completionHandler(presentationOptions);
}
_foregroundUniqueIdentifier = notificationIdentifier;
}

// Called when a user interacts with a notification.
Expand Down