diff --git a/native/ios/Comm/AppDelegate.mm b/native/ios/Comm/AppDelegate.mm --- a/native/ios/Comm/AppDelegate.mm +++ b/native/ios/Comm/AppDelegate.mm @@ -337,11 +337,13 @@ TemporaryMessageStorage *temporaryStorage = [[TemporaryMessageStorage alloc] init]; NSArray *messages = [temporaryStorage readAndClearMessages]; + + if (sendBackgroundMessagesInfosToJS && messages && messages.count) { + [CommIOSNotifications + didReceiveBackgroundMessageInfos:@{@"messageInfosArray" : messages}]; + } + for (NSString *message in messages) { - if (sendBackgroundMessagesInfosToJS) { - [CommIOSNotifications - didReceiveBackgroundMessageInfos:@{@"messageInfos" : message}]; - } std::string messageInfos = std::string([message UTF8String]); comm::GlobalDBSingleton::instance.scheduleOrRun([messageInfos]() mutable { comm::MessageOperationsUtilities::storeMessageInfos(messageInfos); diff --git a/native/push/ios.js b/native/push/ios.js --- a/native/push/ios.js +++ b/native/push/ios.js @@ -81,7 +81,9 @@ remoteNotificationsRegistrationFailed: [void], notificationReceivedForeground: [CoreIOSNotificationData], notificationOpened: [CoreIOSNotificationData], - notificationReceivedBackground: [{ +messageInfos: ?string }], + notificationReceivedBackground: [ + { +messageInfosArray: $ReadOnlyArray }, + ], }>, > { return new NativeEventEmitter(CommIOSNotifications); diff --git a/native/push/push-handler.react.js b/native/push/push-handler.react.js --- a/native/push/push-handler.react.js +++ b/native/push/push-handler.react.js @@ -540,11 +540,11 @@ }; iosBackgroundNotificationReceived = backgroundData => { - const convertedMessageInfos = convertNotificationMessageInfoToNewIDSchema( - backgroundData.messageInfos, - ); + const convertedMessageInfos = backgroundData.messageInfosArray + .flatMap(convertNotificationMessageInfoToNewIDSchema) + .filter(Boolean); - if (!convertedMessageInfos) { + if (!convertedMessageInfos.length) { return; }