Skip to content

SDK-99 Add async/await variants for disablePush#1067

Merged
sumeruchat merged 2 commits into
masterfrom
fix/SDK-99-disablepush-async-await
Jun 2, 2026
Merged

SDK-99 Add async/await variants for disablePush#1067
sumeruchat merged 2 commits into
masterfrom
fix/SDK-99-disablepush-async-await

Conversation

@sumeruchat

@sumeruchat sumeruchat commented May 22, 2026

Copy link
Copy Markdown
Contributor

What

Adds Swift concurrency overloads for the disablePush APIs so callers can await them. This was the only remaining piece of SDK-99 after offline-retry (SDK-297) and the success/fail callbacks already shipped.

Changes

  • Add disableDeviceForCurrentUser() async throws and disableDeviceForAllUsers() async throws on IterableAPI, wrapping the existing completion-handler APIs via withCheckedThrowingContinuation.
  • Throw the public SendRequestError on failure (carries the reason/data from OnFailureHandler); an NSLock-backed guard makes resume exactly-once.
  • Preflight throws "Iterable SDK is not initialized" instead of hanging the await on the existing silent not-initialized path (the completion methods call neither handler when uninitialized).
  • @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) + @nonobjc so existing methods and the Obj-C surface stay untouched (base target remains iOS 10).

Impact

  • Breaking changes: None — purely additive overloads; existing parameterless/completion-handler methods and Obj-C selectors are unchanged.
  • Dependencies: None.
  • Performance: Negligible — a thin continuation wrapper over the existing call path.

Testing

How to test:

  1. Run ./agent_build.sh (succeeds) and ./agent_test.sh (unit 605 / notification-extension 12 / offline-events 90, 0 failures).
  2. From an iOS 13+ target after IterableAPI.initialize…: try await IterableAPI.disableDeviceForCurrentUser() → a disableDevice request is sent with the token.
  3. Force a server failure (e.g. 400) → the call throws SendRequestError carrying the response reason/data.
  4. Call before initializing the SDK → throws "Iterable SDK is not initialized" and does not hang.

Jira: https://iterable.atlassian.net/browse/SDK-99

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.54%. Comparing base (2f85293) to head (9ef0654).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1067      +/-   ##
==========================================
+ Coverage   71.42%   71.54%   +0.11%     
==========================================
  Files         113      113              
  Lines        9410     9438      +28     
==========================================
+ Hits         6721     6752      +31     
+ Misses       2689     2686       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sumeruchat sumeruchat self-assigned this May 22, 2026
@sumeruchat sumeruchat requested a review from joaodordio May 22, 2026 09:08
@franco-zalamena-iterable

Copy link
Copy Markdown
Contributor

Does iOS have changelog entries only on the release or should we add it in this pr?

Adds Swift concurrency overloads for the disablePush APIs:
- disableDeviceForCurrentUser() async throws
- disableDeviceForAllUsers() async throws

Both are availability-gated (@available iOS 13 / macOS 10.15 / tvOS 13 /
watchOS 6) and @nonobjc, so the existing parameterless and
completion-handler methods — and the Obj-C surface — are unchanged.

Each overload wraps the existing completion-handler API via
withCheckedThrowingContinuation, throwing the public SendRequestError on
failure (carrying the reason/data from OnFailureHandler). A small
NSLock-backed resume-once guard prevents double-resume, and an explicit
preflight throws "Iterable SDK is not initialized" rather than creating a
continuation that would hang on the existing silent not-initialized path.

The disablePush offline-retry user story shipped separately under
SDK-297, and registerDevice retry is tracked in SDK-108; this ticket was
rescoped to the async/await wrappers only.

Tests cover success (current + all users), failure throwing
SendRequestError with the right reason/data, and the not-initialized
throw (verifying it does not hang).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joaodordio joaodordio force-pushed the fix/SDK-99-disablepush-async-await branch from bbb29b9 to 2e21d39 Compare June 1, 2026 13:09
…ush-async-await

* origin/master:
  SDK-108 Route registerToken through OfflineRequestProcessor for network-failure retry (#1068)
  SDK-300 Add OnSuccess/OnFailure handlers to logoutUser (#1069)
  SDK-469 Fix CodeQL string length conflation in deep link check (#1071)
@sumeruchat sumeruchat merged commit 3ac2f02 into master Jun 2, 2026
15 checks passed
@sumeruchat sumeruchat deleted the fix/SDK-99-disablepush-async-await branch June 2, 2026 14:14
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.

2 participants