Skip to content

Commit 9641884

Browse files
committed
Always remove the window when an IAM is dismissed
Cherry pick #1276
1 parent 0291cfa commit 9641884

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
@@ -737,7 +738,7 @@ - (void)messageViewControllerWasDismissed:(OSInAppMessageInternal *)message disp
737738
[self persistInAppMessageForRedisplay:showingIAM];
738739
}
739740
// Reset the IAM viewController to prepare for next IAM if one exists
740-
self.viewController = nil;
741+
[self cleanUpInAppWindow];
741742
// Reset time since last IAM
742743
[self setAndPersistTimeSinceLastMessage];
743744

@@ -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

Comments
 (0)