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

MOB-8445 #738

Merged
merged 3 commits into from
May 21, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -870,11 +870,7 @@ public void inAppConsume(@NonNull String messageId) {
*/
public void inAppConsume(@NonNull String messageId, @Nullable IterableHelper.SuccessHandler successHandler, @Nullable IterableHelper.FailureHandler failureHandler) {
IterableInAppMessage message = getInAppManager().getMessageById(messageId);
if (message == null) {
IterableLogger.e(TAG, "inAppConsume: message is null");
if (failureHandler != null) {
failureHandler.onFailure("inAppConsume: message is null", null);
}
if (checkIfMessageIsNull(message, failureHandler)) {
return;
}
inAppConsume(message, null, null, successHandler, failureHandler);
Expand All @@ -894,6 +890,9 @@ public void inAppConsume(@NonNull IterableInAppMessage message, @Nullable Iterab
if (!checkSDKInitialization()) {
return;
}
if (checkIfMessageIsNull(message, null)) {
return;
}
apiClient.inAppConsume(message, source, clickLocation, inboxSessionId, null, null);
}

Expand All @@ -912,9 +911,31 @@ public void inAppConsume(@NonNull IterableInAppMessage message, @Nullable Iterab
if (!checkSDKInitialization()) {
return;
}
if (checkIfMessageIsNull(message, failureHandler)) {
return;
}
apiClient.inAppConsume(message, source, clickLocation, inboxSessionId, successHandler, failureHandler);
}

/**
* Handles the case when the provided message is null.
* If the message is null and a failure handler is provided, it calls the onFailure method of the failure handler.
*
* @param message The in-app message to be checked.
* @param failureHandler The failure handler to be called if the message is null.
* @return True if the message is null, false otherwise.
*/
private boolean checkIfMessageIsNull(@Nullable IterableInAppMessage message, @Nullable IterableHelper.FailureHandler failureHandler) {
if (message == null) {
IterableLogger.e(TAG, "inAppConsume: message is null");
if (failureHandler != null) {
failureHandler.onFailure("inAppConsume: message is null", null);
}
return true;
}
return false;
}

/**
* Tracks a click on the uri if it is an iterable link.
* @param uri the
Expand Down
Loading