@@ -448,6 +448,7 @@ - (void)presentInAppPreviewMessage:(OSInAppMessageInternal *)message {
448448- (void )displayMessage : (OSInAppMessageInternal *)message {
449449 // Check if the app disabled IAMs for this device before showing an IAM
450450 if (_isInAppMessagingPaused && !message.isPreview ) {
451+ [self cleanUpInAppWindow ];
451452 [OneSignalLog onesignalLog: ONE_S_LL_VERBOSE message: @" In app messages will not show while paused" ];
452453 return ;
453454 }
@@ -749,6 +750,19 @@ - (void)messageViewControllerWasDismissed:(OSInAppMessageInternal *)message disp
749750 }
750751}
751752
753+ - (void )cleanUpInAppWindow {
754+ self.viewController = nil ;
755+ if (self.window ) {
756+ /*
757+ Hide the top level IAM window
758+ After the IAM window is hidden, iOS will automatically promote the main window
759+ This also re-shows the keyboard automatically if it had focus in a text input
760+ */
761+ self.window .hidden = true ;
762+ self.window = nil ;
763+ }
764+ }
765+
752766- (void )setAndPersistTimeSinceLastMessage {
753767 NSDate *timeSinceLastMessage = [NSDate new ];
754768 [self .triggerController timeSinceLastMessage: timeSinceLastMessage];
@@ -768,21 +782,12 @@ - (void)evaluateMessageDisplayQueue {
768782 [self displayMessage: self .messageDisplayQueue.firstObject];
769783 return ;
770784 } else {
771- [self hideWindow ];
785+ [self cleanUpInAppWindow ];
772786 // Evaulate any IAMs (could be new IAM or added trigger conditions)
773787 [self evaluateMessages ];
774788 }
775789}
776790
777- /*
778- Hide the top level IAM window
779- After the IAM window is hidden, iOS will automatically promote the main window
780- This also re-shows the keyboard automatically if it had focus in a text input
781- */
782- - (void )hideWindow {
783- self.window .hidden = true ;
784- }
785-
786791- (void )persistInAppMessageForRedisplay : (OSInAppMessageInternal *)message {
787792 // If the IAM doesn't have the re display prop or is a preview IAM there is no need to save it
788793 if (![message.displayStats isRedisplayEnabled ] || message.isPreview ) {
0 commit comments