Skip to content

Commit

Permalink
Merge pull request #738 from Iterable/MOB-8445
Browse files Browse the repository at this point in the history
MOB-8445
  • Loading branch information
Ayyanchira authored May 21, 2024
2 parents fa056fe + e37178a commit d026992
Showing 1 changed file with 26 additions and 5 deletions.
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

0 comments on commit d026992

Please sign in to comment.