Skip to content

Commit 5848dd9

Browse files
helenafordlesnitsky
authored andcommitted
fix(messaging, iOS): revert onMessage event handler commit which causes another bug (#6878)
1 parent cebce3a commit 5848dd9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/firebase_messaging/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,11 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
286286
NSDictionary *notificationDict =
287287
[FLTFirebaseMessagingPlugin NSDictionaryFromUNNotification:notification];
288288

289-
// Send an `onMessage` event
290-
[_channel invokeMethod:@"Messaging#onMessage" arguments:notificationDict];
289+
// Don't send an event if contentAvailable is true - application:didReceiveRemoteNotification
290+
// will send the event for us, we don't want to duplicate them.
291+
if (!notificationDict[@"contentAvailable"]) {
292+
[_channel invokeMethod:@"Messaging#onMessage" arguments:notificationDict];
293+
}
291294
}
292295

293296
// Forward on to any other delegates amd allow them to control presentation behavior.
@@ -398,10 +401,7 @@ - (void)application:(NSApplication *)application
398401
[FLTFirebaseMessagingPlugin remoteMessageUserInfoToDict:userInfo];
399402

400403
if ([NSApplication sharedApplication].isActive) {
401-
// Only handle data-only messages from FCM.
402-
if (userInfo[@"aps"][@"alert"] == nil) {
403-
[_channel invokeMethod:@"Messaging#onMessage" arguments:notificationDict];
404-
}
404+
[_channel invokeMethod:@"Messaging#onMessage" arguments:notificationDict];
405405
} else {
406406
[_channel invokeMethod:@"Messaging#onBackgroundMessage" arguments:notificationDict];
407407
}

0 commit comments

Comments
 (0)