Skip to content

Commit d9c8036

Browse files
committed
fixing IAM didDisplay to fire after animation has completed
1 parent da952cc commit d9c8036

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

iOS_SDK/OneSignalSDK/Source/OSInAppMessageViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
3838

3939
- (void)messageViewDidSelectAction:(OSInAppMessageInternal *)message withAction:(OSInAppMessageAction *)action;
4040
- (void)messageViewDidDisplayPage:(OSInAppMessageInternal *)message withPageId:(NSString *)pageId;
41+
- (void)messageViewControllerDidDisplay:(OSInAppMessageInternal *)message;
4142
- (void)messageViewControllerWillDismiss:(OSInAppMessageInternal *)message;
4243
- (void)messageViewControllerWasDismissed:(OSInAppMessageInternal *)message displayed:(BOOL)displayed;
4344
- (void)webViewContentFinishedLoading:(OSInAppMessageInternal *)message;

iOS_SDK/OneSignalSDK/Source/OSInAppMessageViewController.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,8 @@ - (void)viewWillDisappear:(BOOL)animated {
137137

138138
- (void)applicationIsActive:(NSNotification *)notification {
139139
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:@"Application Active"];
140-
141140
// Animate the showing of the IAM when opening the app from background
142-
[self animateAppearance];
141+
[self animateAppearance:NO];
143142
}
144143

145144
- (void)applicationIsInBackground:(NSNotification *)notification {
@@ -195,7 +194,7 @@ - (void)setupInitialMessageUI {
195194
if (!finished)
196195
return;
197196

198-
[self animateAppearance];
197+
[self animateAppearance:YES];
199198
}];
200199
}
201200

@@ -485,13 +484,17 @@ - (void)dismissCurrentInAppMessage:(BOOL)up withVelocity:(double)velocity {
485484
For banners the initialYConstraint is set to LOW_CONSTRAINT_PRIORITY
486485
For center modal and full screen, the transform is set to CGAffineTransformIdentity (original scale)
487486
*/
488-
- (void)animateAppearance {
487+
- (void)animateAppearance:(BOOL)firstDisplay {
489488
self.initialYConstraint.priority = LOW_CONSTRAINT_PRIORITY;
490489

491490
[UIView animateWithDuration:0.3f animations:^{
492491
self.messageView.hidden = false;
493492
self.messageView.transform = CGAffineTransformIdentity;
494493
[self.view layoutIfNeeded];
494+
} completion:^(BOOL finished) {
495+
if (firstDisplay) {
496+
[self.delegate messageViewControllerDidDisplay:self.message];
497+
}
495498
}];
496499
}
497500

@@ -749,7 +752,7 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIV
749752
[self addConstraintsForMessage];
750753

751754
// Reanimate and show IAM
752-
[self animateAppearance];
755+
[self animateAppearance:NO];
753756
}];
754757
}];
755758
}

iOS_SDK/OneSignalSDK/Source/OSMessagingController.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,14 @@ - (id)getTriggerValueForKey:(NSString *)key {
572572
}
573573

574574
#pragma mark OSInAppMessageViewControllerDelegate Methods
575+
- (void)messageViewControllerDidDisplay:(OSInAppMessageInternal *)message {
576+
[self onDidDisplayInAppMessage:message];
577+
}
578+
579+
- (void)messageViewControllerWillDismiss:(OSInAppMessageInternal *)message {
580+
[self onWillDismissInAppMessage:message];
581+
}
582+
575583
- (void)messageViewControllerWasDismissed:(OSInAppMessageInternal *)message displayed:(BOOL)displayed {
576584
@synchronized (self.messageDisplayQueue) {
577585
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:@"Dismissing IAM and preparing to show next IAM"];
@@ -604,10 +612,6 @@ - (void)messageViewControllerWasDismissed:(OSInAppMessageInternal *)message disp
604612
}
605613
}
606614

607-
- (void)messageViewControllerWillDismiss:(OSInAppMessageInternal *)message {
608-
[self onWillDismissInAppMessage:message];
609-
}
610-
611615
- (void)evaluateMessageDisplayQueue {
612616
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:@"Evaluating message display queue"];
613617
// No IAMs are showing currently
@@ -847,7 +851,6 @@ - (void)webViewContentFinishedLoading:(OSInAppMessageInternal *)message {
847851
[self addKeySceneToWindow:self.window];
848852

849853
[self.window makeKeyAndVisible];
850-
[self onDidDisplayInAppMessage:message];
851854
}
852855

853856
// Required to display if the app is using a Scene

0 commit comments

Comments
 (0)