@@ -435,6 +435,7 @@ - (void)messageViewControllerWasDismissed {
435435 OSInAppMessage *showingIAM = self.messageDisplayQueue .firstObject ;
436436 [self .seenInAppMessages addObject: showingIAM.messageId];
437437 [OneSignalUserDefaults.initStandard saveSetForKey: OS_IAM_SEEN_SET_KEY withValue: self .seenInAppMessages];
438+ [OneSignal onesignal_Log: ONE_S_LL_VERBOSE message: [NSString stringWithFormat: @" Dismissing IAM save seenInAppMessages: %@ " , _seenInAppMessages]];
438439 // Remove dismissed IAM from messageDisplayQueue
439440 [self .messageDisplayQueue removeObjectAtIndex: 0 ];
440441 [self persistInAppMessageForRedisplay: showingIAM];
@@ -477,8 +478,8 @@ - (void)hideWindow {
477478}
478479
479480- (void )persistInAppMessageForRedisplay : (OSInAppMessage *)message {
480- // If the IAM doesn't have the re display prop there is no need to save it
481- if (![message.displayStats isRedisplayEnabled ])
481+ // If the IAM doesn't have the re display prop or is a preview IAM there is no need to save it
482+ if (![message.displayStats isRedisplayEnabled ] || message. isPreview )
482483 return ;
483484
484485 let displayTimeSeconds = self.dateGenerator ();
@@ -511,6 +512,7 @@ - (void)handlePromptActions:(NSArray<NSObject<OSInAppMessagePrompt> *> *)promptA
511512 _currentPromptAction.hasPrompted = YES ;
512513 [_currentPromptAction handlePrompt: ^(BOOL accepted) {
513514 _currentPromptAction = nil ;
515+ [OneSignal onesignal_Log: ONE_S_LL_VERBOSE message: [NSString stringWithFormat: @" IAM prompt to handle finished accepted: %@ " , accepted ? @" YES" : @" NO" ]];
514516 [self handlePromptActions: promptActions];
515517 }];
516518 } else if (!_viewController) { // IAM dismissed by action
@@ -531,11 +533,30 @@ - (void)messageViewDidSelectAction:(OSInAppMessage *)message withAction:(OSInApp
531533 if (self.actionClickBlock )
532534 self.actionClickBlock (action);
533535
536+ if (message.isPreview ) {
537+ [self processPreviewInAppMessage: message withAction: action];
538+ return ;
539+ }
540+
541+ // The following features are for non preview IAM
542+ // Make sure no click, outcome, tag tracking is performed for IAM previews
534543 [self sendClickRESTCall: message withAction: action];
535544 [self sendTagCallWithAction: action];
536545 [self sendOutcomes: action.outcomes];
537546}
538547
548+ /*
549+ * Show the developer what will happen with a non IAM preview
550+ */
551+ - (void )processPreviewInAppMessage : (OSInAppMessage *)message withAction : (OSInAppMessageAction *)action {
552+ if (action.tags )
553+ [OneSignal onesignal_Log: ONE_S_LL_VERBOSE message: [NSString stringWithFormat: @" Tags detected inside of the action click payload, ignoring because action came from IAM preview\n Tags: %@ " , action.tags.jsonRepresentation]];
554+
555+ if (action.outcomes .count > 0 ) {
556+ [OneSignal onesignal_Log: ONE_S_LL_VERBOSE message: [NSString stringWithFormat: @" Outcomes detected inside of the action click payload, ignoring because action came from IAM preview: %@ " , [action.outcomes description ]]];
557+ }
558+ }
559+
539560/*
540561* Checks if a click being available:
541562* 1. Redisplay is enabled and click is available within message
@@ -548,11 +569,10 @@ - (BOOL)isClickAvailable:(OSInAppMessage *)message withClickId:(NSString *)click
548569
549570- (void )sendClickRESTCall : (OSInAppMessage *)message withAction : (OSInAppMessageAction *)action {
550571 let clickId = action.clickId ;
551- // Make sure no click tracking is performed for IAM previews
552572 // If the IAM clickId exists within the cached clickedClickIds return early so the click is not tracked
553573 // unless that click is from an IAM with redisplay
554574 // Handles body, button, or image clicks
555- if (message. isPreview || ![self isClickAvailable: message withClickId: clickId])
575+ if (![self isClickAvailable: message withClickId: clickId])
556576 return ;
557577 // Add clickId to clickedClickIds
558578 [self .clickedClickIds addObject: clickId];
0 commit comments