The scenario: local sign-out can finish before remote cleanup
A patient should be able to leave an account while the network is unavailable. Remote registration cleanup still matters: ordinary push, call notifications and Live Activity updates have their own server-side records. A useful design separates immediate local session removal from the best-effort requests that retire those records.
The selected Movo-X iOS core accepts credentials captured before local sign-out and attempts remote cleanup independently of the current session manager. Four SignOutTokensTests and five RevocationTests passed using fake HTTP transport. The inspected app model links that core to local wiping and a detached cleanup task. Device background execution and actual provider state were not exercised.
Capture the old session without restoring it to the app
The inspected app-model sequence obtains the session being signed out, awaits local wiping, then starts the remote operation when captured credentials exist. The core method uses those credentials directly rather than asking the now signed-out session manager for an active bearer. An existing test constructs a client whose in-memory live session is already absent.
This separates the authority needed to finish an old account’s remote work from the authority shown to the current UI. It does not mean the app should restore the old session while retrying. The selected source records pending refresh credentials through a separate revocation-store abstraction; the portable tests do not inspect a real Keychain or establish its accessibility and retention policy.
Attempt each cleanup endpoint even when an earlier one fails
The selected method attempts four requests in order: delete the installation’s ordinary push registration, delete VoIP tokens, delete Live Activity tokens and post session logout. The existing order fixture checks methods, paths, captured Authorization header, absent bodies and request IDs.
Other cases make the VoIP delete time out or fail and verify that later requests, including logout, are still attempted. An all-offline fixture records four attempts and a retry outcome without a thrown transport error escaping. These cases show independent request progression. They do not prove that a real server accepted every deletion or that a late provider delivery can no longer reach a physical device.
Use a per-request timeout without calling it a total deadline
The selected default timeout is eight seconds and is assigned to each cleanup request. When an access token needs refresh, that refresh operation uses the supplied timeout too. The method performs sequential requests, so eight seconds is not an end-to-end deadline for all remote work.
The tests check the configured request timeout, not elapsed wall-clock duration under a real network. The app-model source starts a background task wrapper around detached cleanup, but its presence alone does not establish how long iOS will keep the process alive. Acceptance needs cancellation, suspension, transport and foreground recovery cases rather than a timing promise inferred from one request property.
Refresh only when the captured access token needs it
The inspected core refreshes when the captured access token is missing or its expiry is less than fifteen seconds away at the supplied current time. The restored-session case supplies no current bearer, checks a refresh request and verifies that the later logout uses the refreshed access token.
The refresh result also updates the stored-session value returned for any later retry. An existing case makes refresh return an unauthorized response and expects a terminal outcome. These are selected fake-response cases, not an audit of token validity on an installed service. The exact expiry boundary, every refresh failure shape and concurrent account transitions need their own acceptance cases before broader claims.
Define done as a client policy result
For the four cleanup responses, the selected method treats successful HTTP status, unauthorized and not found as finished. A missing response or another status leaves a retry outcome. Existing cases cover success, feature-absent not-found responses, server failure and transport failure. This makes the local policy inspectable and repeatable.
A terminal unauthorized or not-found result does not physically demonstrate that every old provider registration was erased. It means the selected client has classified that response as requiring no further attempt. The server’s logout contract, registration ownership and disabled-feature behaviour must support that policy. Keep those authoritative contracts separate from the local outcome enum in an engineering handover.
Retry pending work without claiming unlimited retention
The core revocation queue stores pending sessions through an injected abstraction. Its enqueue path deduplicates by refresh token and retains at most five items, keeping the most recently appended entries. Its drain path attempts the loaded work and retains entries that still need a later retry. These bounded policies are visible in source.
The existing offline-then-online test enqueues one failed revocation in an in-memory store and verifies that a later successful drain clears it. That fixture does not establish queue persistence across restart, every interleaving of enqueue and drain or what happens operationally when more than five sessions accumulate. A bounded queue needs an explicit product policy for those limits rather than an unlimited-cleanup claim.
Keep local privacy surfaces in a separate acceptance checklist
A remote token endpoint and a locally visible notification are different surfaces. These portable Swift cases never create a notification, start a call, display a Live Activity or inspect a locked screen. They also do not establish the exact content removed by the app’s local wipe. Those concerns connect to this flow without being covered by its fake HTTP responses.
Use controlled accounts and devices to test local removal, late incoming messages, relaunch while a revocation is pending and signing into another account. Inspect the server’s effective registration and session state independently. The important observable outcome is what authority and information remain at each boundary, including after recovery from an interrupted cleanup task.
A practical sign-out lifecycle handover
Retain the nine portable cases, source hashes and request expectations as the core-method evidence. Add the installed revocation-store implementation, queue-capacity policy, concurrency schedules, background-expiration recovery and current server contracts to the acceptance plan. Verify provider effects with controlled registrations rather than actual patient messages.
For a CTO, the resulting architecture is easier to reason about: local sign-out changes the active account state; captured credentials support limited remote retirement; each cleanup request has its own outcome; pending work has bounded retention. This chapter establishes selected client behaviours and source intent. It does not certify APNs delivery cessation, Keychain erasure or complete production session invalidation.
Compare the reviewed boundaries
Local sign-out and remote cleanup produce different evidence
On smaller screens, scroll across to compare every column. Keyboard users can focus the table and use the arrow keys.
| Boundary | Selected evidence | Separate acceptance |
|---|---|---|
| Captured authority | Fake requests retain the captured bearer | Current server scope and account isolation |
| Independent cleanup | Later requests survive earlier failures | Actual provider/registration effects |
| Retry classification | Done or retryLater from fake responses | Authoritative response semantics |
| Pending queue | One offline item later drains in memory | Persistence, capacity, concurrency and iOS lifetime |
Illustrative control flow
Pseudocode summarizing the decision boundary. It is not copied production code or a deployment instruction.
captured = remove_local_session()
await wipe_local_account_state()
if captured:
outcome = attempt_independent_remote_cleanup(captured)
if outcome_requires_retry: enqueue_bounded_pending_work(outcome.session)
# Each request has its own timeout; terminal policy is not provider-erasure evidence.About this engineering series
Written by Omer Muneer Qazi from a review of Movo-X implementation and dated engineering records. This article explains source behaviour and historical observations; current production, clinical outcomes and store availability require their own verification. Examples are synthetic and proposed test cases are identified as such.
Explore the Movo-X engineering series → · Related implementation experience →
Discuss a similar engineering problem
Send the workflow, current platform and the decision your team needs to make. I can help define an implementation or review scope with concrete acceptance evidence.
Discuss your project on WhatsApp ↗