@@ -3330,4 +3330,92 @@ - (void)testTimezoneId {
33303330 XCTAssertEqualObjects (OneSignalClientOverrider.lastHTTPRequest [@" timezone_id" ], mockTimezone.name );
33313331
33323332}
3333+
3334+ - (void )testParseCollapseIdInOSData {
3335+ NSDictionary *apsOsData = @{
3336+ @" aps" : @{
3337+ @" content-available" : @1 ,
3338+ @" mutable-content" : @1 ,
3339+ @" alert" : @" Message Body" ,
3340+ @" relevance-score" : @0.15 ,
3341+ @" interruption-level" : @" time-sensitive" ,
3342+ },
3343+ @" os_data" : @{
3344+ @" i" : @" notif id" ,
3345+ @" ti" : @" templateId123" ,
3346+ @" tn" : @" Template name" ,
3347+ @" collapse_id" : @" test_id"
3348+ }};
3349+ OSNotification *notification = [OSNotification parseWithApns: apsOsData];
3350+ XCTAssertEqualObjects (notification.collapseId , @" test_id" );
3351+ NSDictionary *json = [notification jsonRepresentation ];
3352+ XCTAssertEqualObjects (json[@" collapseId" ], @" test_id" );
3353+ }
3354+
3355+ - (void )testParseCollapseIdInCustom {
3356+ NSDictionary *apsCustom = @{
3357+ @" aps" : @{
3358+ @" content-available" : @1 ,
3359+ @" mutable-content" : @1 ,
3360+ @" alert" : @" Message Body" ,
3361+ @" relevance-score" : @0.15 ,
3362+ @" interruption-level" : @" time-sensitive" ,
3363+ },
3364+ @" custom" : @{
3365+ @" i" : @" notif id" ,
3366+ @" ti" : @" templateId123" ,
3367+ @" tn" : @" Template name" ,
3368+ @" collapse_id" : @" test_id"
3369+ }};
3370+ OSNotification *notification = [OSNotification parseWithApns: apsCustom];
3371+ XCTAssertEqualObjects (notification.collapseId , @" test_id" );
3372+ NSDictionary *json = [notification jsonRepresentation ];
3373+ XCTAssertEqualObjects (json[@" collapseId" ], @" test_id" );
3374+ }
3375+
3376+ - (void ) testParseCollapseIdFromNotificationRequestWithCustom {
3377+ NSDictionary *apsCustom = @{
3378+ @" aps" : @{
3379+ @" content-available" : @1 ,
3380+ @" mutable-content" : @1 ,
3381+ @" alert" : @" Message Body" ,
3382+ @" relevance-score" : @0.15 ,
3383+ @" interruption-level" : @" time-sensitive" ,
3384+ },
3385+ @" custom" : @{
3386+ @" i" : @" notif id" ,
3387+ @" ti" : @" templateId123" ,
3388+ @" tn" : @" Template name"
3389+ }};
3390+ id notifResponse = [UnitTestCommonMethods createBasiciOSNotificationResponseWithPayload: apsCustom];
3391+
3392+ UNMutableNotificationContent * content = [OneSignal didReceiveNotificationExtensionRequest: [notifResponse notification ].request withMutableNotificationContent: nil
3393+ withContentHandler: nil ];
3394+
3395+ XCTAssertEqualObjects (content.userInfo [@" custom" ][@" collapse_id" ], @" test_id" );
3396+ }
3397+
3398+ - (void ) testParseCollapseIdFromNotificationRequestWithOSData {
3399+ NSDictionary *apsOSData = @{
3400+ @" aps" : @{
3401+ @" content-available" : @1 ,
3402+ @" mutable-content" : @1 ,
3403+ @" alert" : @" Message Body" ,
3404+ @" relevance-score" : @0.15 ,
3405+ @" interruption-level" : @" time-sensitive" ,
3406+ },
3407+ @" os_data" : @{
3408+ @" i" : @" notif id" ,
3409+ @" ti" : @" templateId123" ,
3410+ @" tn" : @" Template name"
3411+ }};
3412+ id notifResponse = [UnitTestCommonMethods createBasiciOSNotificationResponseWithPayload: apsOSData];
3413+
3414+ UNMutableNotificationContent * content = [OneSignal didReceiveNotificationExtensionRequest: [notifResponse notification ].request withMutableNotificationContent: nil
3415+ withContentHandler: nil ];
3416+
3417+
3418+ XCTAssertEqualObjects (content.userInfo [@" os_data" ][@" collapse_id" ], @" test_id" );
3419+ }
3420+
33333421@end
0 commit comments