From 2d70ddd02624a644b1c980ef32ad4ddfd3a40a3c Mon Sep 17 00:00:00 2001 From: Mritunjay Date: Sat, 28 Mar 2026 17:06:30 +0530 Subject: [PATCH 1/4] fix(messaging,ios): emit messaging_notification_opened only for default notification action Ensure messaging_notification_opened is emitted only when the UNNotificationDefaultActionIdentifier is triggered. This prevents onNotificationOpened from being invoked for custom notification actions. --- .../RNFBMessaging+UNUserNotificationCenter.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m index 78db8f4aa0..feec8f75ae 100644 --- a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m +++ b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m @@ -153,6 +153,16 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { + if (![[response actionIdentifier] isEqualToString:UNNotificationDefaultActionIdentifier]){ + if (_originalDelegate != nil && originalDelegateRespondsTo.didReceiveNotificationResponse) { + [_originalDelegate userNotificationCenter:center + didReceiveNotificationResponse:response + withCompletionHandler:completionHandler]; + } else { + completionHandler(); + } + return; + } NSDictionary *remoteNotification = response.notification.request.content.userInfo; if (remoteNotification[@"gcm.message_id"]) { NSDictionary *notificationDict = From 52443ef42a248723c155e32190217d0e1b885134 Mon Sep 17 00:00:00 2001 From: Mritunjay Date: Sat, 28 Mar 2026 17:17:29 +0530 Subject: [PATCH 2/4] fix(messaging,ios) avoiding code duplication --- .../RNFBMessaging+UNUserNotificationCenter.m | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m index feec8f75ae..f15a0116cd 100644 --- a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m +++ b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m @@ -153,23 +153,15 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { - if (![[response actionIdentifier] isEqualToString:UNNotificationDefaultActionIdentifier]){ - if (_originalDelegate != nil && originalDelegateRespondsTo.didReceiveNotificationResponse) { - [_originalDelegate userNotificationCenter:center - didReceiveNotificationResponse:response - withCompletionHandler:completionHandler]; - } else { - completionHandler(); + if ([[response actionIdentifier] isEqualToString:UNNotificationDefaultActionIdentifier]) { + NSDictionary *remoteNotification = response.notification.request.content.userInfo; + if (remoteNotification[@"gcm.message_id"]) { + NSDictionary *notificationDict = + [RNFBMessagingSerializer remoteMessageUserInfoToDict:remoteNotification]; + [[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_notification_opened" + body:notificationDict]; + _initialNotification = notificationDict; } - return; - } - NSDictionary *remoteNotification = response.notification.request.content.userInfo; - if (remoteNotification[@"gcm.message_id"]) { - NSDictionary *notificationDict = - [RNFBMessagingSerializer remoteMessageUserInfoToDict:remoteNotification]; - [[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_notification_opened" - body:notificationDict]; - _initialNotification = notificationDict; } if (_originalDelegate != nil && originalDelegateRespondsTo.didReceiveNotificationResponse) { From 9764265ff46aaf4cfa4a3f49af4d6a69c89aefaa Mon Sep 17 00:00:00 2001 From: Mritunjay Date: Sat, 28 Mar 2026 19:56:02 +0530 Subject: [PATCH 3/4] combining if statements --- .../RNFBMessaging+UNUserNotificationCenter.m | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m index f15a0116cd..085a934bd5 100644 --- a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m +++ b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m @@ -153,17 +153,16 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { - if ([[response actionIdentifier] isEqualToString:UNNotificationDefaultActionIdentifier]) { - NSDictionary *remoteNotification = response.notification.request.content.userInfo; - if (remoteNotification[@"gcm.message_id"]) { - NSDictionary *notificationDict = - [RNFBMessagingSerializer remoteMessageUserInfoToDict:remoteNotification]; - [[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_notification_opened" - body:notificationDict]; - _initialNotification = notificationDict; - } + NSDictionary *remoteNotification = response.notification.request.content.userInfo; + if ([[response actionIdentifier] isEqualToString:UNNotificationDefaultActionIdentifier] && remoteNotification[@"gcm.message_id"]) { + NSDictionary *notificationDict = + [RNFBMessagingSerializer remoteMessageUserInfoToDict:remoteNotification]; + [[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_notification_opened" + body:notificationDict]; + _initialNotification = notificationDict; } + if (_originalDelegate != nil && originalDelegateRespondsTo.didReceiveNotificationResponse) { [_originalDelegate userNotificationCenter:center didReceiveNotificationResponse:response From 4f2537ba9f5e3e101b92e98ec0d5075131d6d9fa Mon Sep 17 00:00:00 2001 From: Mritunjay Date: Sat, 28 Mar 2026 19:56:44 +0530 Subject: [PATCH 4/4] removing white space --- .../ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m index 085a934bd5..bd4ba5175f 100644 --- a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m +++ b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m @@ -162,7 +162,6 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center _initialNotification = notificationDict; } - if (_originalDelegate != nil && originalDelegateRespondsTo.didReceiveNotificationResponse) { [_originalDelegate userNotificationCenter:center didReceiveNotificationResponse:response