SDK-478 resolve init promise immediately on iOS SDK, matching Android SDK#869
SDK-478 resolve init promise immediately on iOS SDK, matching Android SDK#869joaodordio wants to merge 2 commits into
Conversation
|
Coverage Impact This PR will not change total coverage. 🚦 See full report on Qlty Cloud »🛟 Help
|
|
Note Heads up to reviewers: the failing Evidence. The job has been red on every Root cause. Why it can't be from this PR. The diff is iOS-only - no Android files, no Gradle files, no workflow files touched. Reproduces verbatim on Suggested follow-up (separate PR). Either add an explicit ex.autolinkLibrariesFromCommand([
"node",
"node_modules/@react-native-community/cli/build/bin.js",
"config"
]) |

🔹 JIRA Ticket(s) if any
✏️ Description
What this changes
The iOS bridge for
Iterable.initializenow resolves the JS promise immediately after calling the native SDK's synchronous initializer, matching the behavior the Android bridge has had since day one. The native iOS SDK is fully usable the momentIterableAPI.initialize(...)returns; nothing about JS-side correctness needs the in-app message fetch to complete before the promise resolves.Why
The promise contract was originally introduced in commit
4c357126(Feb 2021) with the intent of letting JS callersawait Iterable.initialize()to know that the SDK is ready. The implementation wired the promise to the iOS SDK'sIterableAPI.initialize2(callback:)overload, which is documented in the iOS SDK as an internal staging/test endpoint override and whose callback fires when the first in-app messages fetch settles, not when the SDK is ready to use. This was a workable approximation in 2021 because the fetch typically settled in under 2s on healthy networks.Two later changes made the gap between "SDK ready" and "first fetch settles" observable as a multi-second to multi-minute hang:
start()that runs on the calling thread, which for cross-platform bridges is the main thread (DispatchQueue.main.async).Prior consolidation attempts include commit
c07b5ccd(Oct 2025) which made exactly the change this PR makes but did not survive the merge to master, and commitf37cc10b(April 2026) which added a 10s timeout band-aid as part of SDK-392 but also did not survive to master.This PR consolidates the correction: bridge calls sync
IterableAPI.initialize(...)and resolvestrueimmediately. Behavior now matches Android'sRNIterableAPIModuleImpl.initializeWithApiKeywhich has done the same since its introduction. The internalinitialize2(endpoint override) path is preserved for staging/test callers but its callback is no longer waited on.Compatibility
Documented usage in
iterable-docsalready showsIterable.initialize('<KEY>', config);withoutawait, aligned with the new behavior. Any caller relying on the old wait semantics (the promise resolving only after the in-app fetch attempt) would have been exposed to an unbounded hang under SDK-478 conditions, so the likelihood of customer code depending on it is low. The behavior change is called out explicitly in the CHANGELOG and the release notes.Tests
New SDK-478 contract-pin tests in
src/core/classes/IterableApi.test.ts:initializeWithApiKeyandinitialize2WithApiKeyboth assert that the JS-side call resolves in under 50ms when the native mock resolves true, pinning the "pure passthrough, no additional await" contract.Linked tickets
iterable-swift-sdk)