From 2740491e32f3c04cf270993d5e7dc6541f67e55d Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Wed, 14 Feb 2024 10:32:11 -0800 Subject: [PATCH] resolve getInitialNotification for local notifications with notification schema Summary: Changelog: [Internal] In the past, local notifications were stored in the launch options as UILocalNotification, whereas remote notifications were stored as NSDict. This means that we had different handling in PushNotificationIOS.js. This condition was not handling the differences in local and remote notifications that JS expected, which I'm fixing here. Reviewed By: ingridwang Differential Revision: D53734086 fbshipit-source-id: 73ef436a232c16de3b72f7236db94012aafdc434 --- .../PushNotificationIOS/RCTPushNotificationManager.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm b/packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm index 3f868f7708d..e366d196aad 100644 --- a/packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm +++ b/packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm @@ -535,13 +535,14 @@ RCT_EXPORT_METHOD(getInitialNotification if (self.initialNotification) { NSDictionary *notificationDict = RCTFormatUNNotificationContent(self.initialNotification.request.content); - NSDictionary *userInfo = notificationDict[@"userInfo"]; if (IsNotificationRemote(self.initialNotification)) { - NSMutableDictionary *userInfoCopy = [userInfo mutableCopy]; + // For backwards compatibility, remote notifications only returns a userInfo dict. + NSMutableDictionary *userInfoCopy = [notificationDict[@"userInfo"] mutableCopy]; userInfoCopy[@"remote"] = @YES; resolve(userInfoCopy); } else { - resolve(userInfo); + // For backwards compatibility, local notifications return the notification. + resolve(notificationDict); } return; }