Skip to content

New IterableEmbeddedUpdateHandler methods for sync failure and success.#989

Open
franco-zalamena-iterable wants to merge 6 commits intomasterfrom
SDK-302-Expose-callbacks
Open

New IterableEmbeddedUpdateHandler methods for sync failure and success.#989
franco-zalamena-iterable wants to merge 6 commits intomasterfrom
SDK-302-Expose-callbacks

Conversation

@franco-zalamena-iterable
Copy link
Contributor

@franco-zalamena-iterable franco-zalamena-iterable commented Feb 11, 2026

🔹 Jira Ticket(s) if any

✏️ Description

Creating new methods regarding sync success and failures for users to be able to act upon result.
Matching listener style from ios side
ios merged pr: Iterable/iterable-swift-sdk#988

@joaodordio joaodordio force-pushed the SDK-302-Expose-callbacks branch from 276b142 to d8bb8e4 Compare March 19, 2026 15:21
Copy link
Collaborator

@sumeruchat sumeruchat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also is the refactoring really necesssary. Any refactor runs the risk of introducing regressions. Lets try to get the minimum changeset that accomplishes the task and has no side effects.

@franco-zalamena-iterable
Copy link
Contributor Author

Also is the refactoring really necesssary. Any refactor runs the risk of introducing regressions. Lets try to get the minimum changeset that accomplishes the task and has no side effects.

Yes i think we should have android and ios matching, this change introduces no behavior change, it is only new callbacks

@sumchattering
Copy link
Contributor

  1. Bug: notifySyncFailed called alongside broadcastSubscriptionInactive for
    inactive subscriptions

This is the most important issue. In the new code:

{ reason, data ->
handleSyncFailure(reason, data) // calls
broadcastSubscriptionInactive() for inactive subs
notifySyncFailed(reason) // ALSO called — always
}

In the original code, the failure handler had an early return after
broadcastSubscriptionInactive(), meaning listeners would only receive
onEmbeddedMessagingDisabled(). Now they receive both
onEmbeddedMessagingDisabled() and onEmbeddedMessagingSyncFailed() for the
SUBSCRIPTION_INACTIVE / Invalid API Key cases.

Recommendation: If this is intentional, document it. If not, either:

  • Return a boolean from handleSyncFailure and conditionally call
    notifySyncFailed, or
  • Move notifySyncFailed into the else branch of handleSyncFailure.
  1. processEmbeddedMessagesResponse only catches JSONException

The catch block in syncMessages catches JSONException, but
processEmbeddedMessagesResponse calls
IterableEmbeddedPlacement.fromJSONObject() which uses getLong() /
getJSONArray() — these throw JSONException, so the malformed-JSON test should
pass. However, if fromJSONObject ever evolves to throw other exceptions
(e.g., NullPointerException from a null optJSONObject), those would propagate
uncaught. Consider whether a broader catch (e: Exception) would be more
defensive here.

Copy link
Member

@joaodordio joaodordio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants