@@ -55,7 +55,14 @@ + (UNMutableNotificationContent*)didReceiveNotificationExtensionRequest:(UNNotif
5555 if (!replacementContent)
5656 replacementContent = [request.content mutableCopy ];
5757
58- let notification = [OSNotification parseWithApns: request.content.userInfo];
58+ /*
59+ Add the collapse Id (request.identifier) to userInfo
60+ so it can be parsed by parseWithApns outside of the extension
61+ */
62+ replacementContent.userInfo = [self userInfoWithCollapseId: replacementContent.userInfo
63+ identifier: request.identifier];
64+
65+ let notification = [OSNotification parseWithApns: replacementContent.userInfo];
5966
6067 // Handle badge count
6168 [OneSignalExtensionBadgeHandler handleBadgeCountWithNotificationRequest: request withNotification: notification withMutableNotificationContent: replacementContent];
@@ -88,6 +95,21 @@ + (UNMutableNotificationContent*)didReceiveNotificationExtensionRequest:(UNNotif
8895 return replacementContent;
8996}
9097
98+ + (NSDictionary *)userInfoWithCollapseId : (NSDictionary *)userInfo identifier : (NSString *)identifier {
99+ NSMutableDictionary *userInfoWithCollapseId = [NSMutableDictionary dictionaryWithDictionary: userInfo];
100+ if (userInfoWithCollapseId[@" os_data" ]) {
101+ NSMutableDictionary *osdataDict = [NSMutableDictionary dictionaryWithDictionary: userInfoWithCollapseId[@" os_data" ]];
102+ osdataDict[@" collapse_id" ] = identifier;
103+ userInfoWithCollapseId[@" os_data" ] = osdataDict;
104+ } else if (userInfoWithCollapseId[@" custom" ]) {
105+ NSMutableDictionary *customDict = [NSMutableDictionary dictionaryWithDictionary: userInfoWithCollapseId[@" custom" ]];
106+ customDict[@" collapse_id" ] = identifier;
107+ userInfoWithCollapseId[@" custom" ] = customDict;
108+ }
109+
110+ return userInfoWithCollapseId;
111+ }
112+
91113+ (UNMutableNotificationContent *)serviceExtensionTimeWillExpireRequest : (UNNotificationRequest *)request
92114 withMutableNotificationContent : (UNMutableNotificationContent *)replacementContent {
93115 if (!replacementContent)
0 commit comments