Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MC-1578 Fix in-apps not discarded #321

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading