Skip to content

Commit

Permalink
Merge pull request #321 from CleverTap/fix-discard-inapps
Browse files Browse the repository at this point in the history
MC-1578 Fix in-apps not discarded
  • Loading branch information
AishwaryaNanna authored Apr 4, 2024
2 parents 12c0b43 + 8fe6966 commit 162a5e6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CleverTapSDK/InApps/CTInAppDisplayManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 13 additions & 13 deletions CleverTapSDK/InApps/CleverTap+InAppsResponseHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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 {
Expand Down

0 comments on commit 162a5e6

Please sign in to comment.