@@ -833,6 +833,32 @@ - (void)testIAMClickedLaunchesAPIRequest {
833833 XCTAssertEqualObjects (OneSignalClientOverrider.lastHTTPRequestType , NSStringFromClass ([OSRequestInAppMessageClicked class ]));
834834}
835835
836+ - (void )testIAMClickWithNoIDLogsError {
837+ let message = [OSInAppMessageTestHelper testMessageJsonWithTriggerPropertyName: OS_DYNAMIC_TRIGGER_KIND_SESSION_TIME withId: @" test_id1" withOperator: OSTriggerOperatorTypeLessThan withValue: @10.0 ];
838+
839+ let registrationResponse = [OSInAppMessageTestHelper testRegistrationJsonWithMessages: @[message]];
840+
841+ // the trigger should immediately evaluate to true and should
842+ // be shown once the SDK is fully initialized.
843+ [OneSignalClientOverrider setMockResponseForRequest: NSStringFromClass ([OSRequestRegisterUser class ]) withResponse: registrationResponse];
844+
845+ [UnitTestCommonMethods initOneSignal_andThreadWait ];
846+
847+ // the message should now be displayed
848+ // simulate a button press (action) on the inapp message with a nil id
849+ let action = [OSInAppMessageAction new ];
850+ action.clickType = @" button" ;
851+ #pragma GCC diagnostic push
852+ #pragma GCC diagnostic ignored "-Wnonnull"
853+ action.clickId = nil ;
854+ #pragma GCC diagnostic pop
855+ let testMessage = [OSInAppMessageInternal instanceWithJson: message];
856+
857+ [OSMessagingController.sharedInstance messageViewDidSelectAction: testMessage withAction: action];
858+ // The action should not send a request due to the nil id but it should not crash
859+ XCTAssertEqualObjects (OneSignalClientOverrider.lastHTTPRequestType , NSStringFromClass ([OSRequestRegisterUser class ]));
860+ }
861+
836862- (void )testIAMClickedLaunchesOutcomeAPIRequest {
837863 [self setOutcomesParamsEnabled ];
838864
0 commit comments