diff --git a/CleverTapSDK/InApps/CTInAppDisplayManager.m b/CleverTapSDK/InApps/CTInAppDisplayManager.m index 7fd9d1ac..a09db86d 100644 --- a/CleverTapSDK/InApps/CTInAppDisplayManager.m +++ b/CleverTapSDK/InApps/CTInAppDisplayManager.m @@ -196,6 +196,11 @@ - (void)_showNotificationIfAvailable { } - (void)prepareNotificationForDisplay:(NSDictionary*)jsonObj { + if (self.inAppRenderingStatus == CleverTapInAppDiscard) { + CleverTapLogDebug(self.config.logLevel, @"%@: InApp Notifications are set to be discarded, not saving and showing the InApp Notification", self); + return; + } + if (!self.instance.isAppForeground) { CleverTapLogInternal(self.config.logLevel, @"%@: Application is not in the foreground, won't prepare in-app: %@", self, jsonObj); return; diff --git a/CleverTapSDK/InApps/CleverTap+InAppsResponseHandler.m b/CleverTapSDK/InApps/CleverTap+InAppsResponseHandler.m index 27869416..3a8b7a9d 100644 --- a/CleverTapSDK/InApps/CleverTap+InAppsResponseHandler.m +++ b/CleverTapSDK/InApps/CleverTap+InAppsResponseHandler.m @@ -50,16 +50,6 @@ - (void)handleInAppResponse:(NSDictionary *)jsonResp { NSString *mode = jsonResp[CLTAP_INAPP_MODE_JSON_RESPONSE_KEY]; [self.inAppStore setMode:mode]; - // Parse SS App Launched notifications - NSArray *inAppNotifsAppLaunched = jsonResp[CLTAP_INAPP_SS_APP_LAUNCHED_JSON_RESPONSE_KEY]; - if (inAppNotifsAppLaunched) { - @try { - [self.inAppEvaluationManager evaluateOnAppLaunchedServerSide:inAppNotifsAppLaunched]; - } @catch (NSException *e) { - CleverTapLogInternal(self.config.logLevel, @"%@: Error evaluating App Launched notifications JSON: %@", self, e.debugDescription); - } - } - // Handle stale in-apps @try { NSArray *stale = jsonResp[CLTAP_INAPP_STALE_JSON_RESPONSE_KEY]; @@ -68,13 +58,23 @@ - (void)handleInAppResponse:(NSDictionary *)jsonResp { CleverTapLogInternal(self.config.logLevel, @"%@: Failed to handle inapp_stale update: %@", self, ex.debugDescription) } - // Parse in-app notifications to be displayed - NSArray *inappsJSON = jsonResp[CLTAP_INAPP_JSON_RESPONSE_KEY]; - if (self.inAppDisplayManager.inAppRenderingStatus == CleverTapInAppDiscard) { CleverTapLogDebug(self.config.logLevel, @"%@: InApp Notifications are set to be discarded, not saving and showing the InApp Notification", self); return; } + + // Parse SS App Launched notifications + NSArray *inAppNotifsAppLaunched = jsonResp[CLTAP_INAPP_SS_APP_LAUNCHED_JSON_RESPONSE_KEY]; + if (inAppNotifsAppLaunched) { + @try { + [self.inAppEvaluationManager evaluateOnAppLaunchedServerSide:inAppNotifsAppLaunched]; + } @catch (NSException *e) { + CleverTapLogInternal(self.config.logLevel, @"%@: Error evaluating App Launched notifications JSON: %@", self, e.debugDescription); + } + } + + // Parse in-app notifications to be displayed + NSArray *inappsJSON = jsonResp[CLTAP_INAPP_JSON_RESPONSE_KEY]; if (inappsJSON) { NSMutableArray *inappNotifs; @try {