The scenario: a token refresh must preserve an opt-out
A device token can change while the account’s notification preference stays the same. If registration silently sends notificationsEnabled true each time, a plumbing operation can reverse a deliberate account setting. The engineering task is to carry the known preference through registration and represent an unknown preference explicitly.
The selected Movo-X Android registrar models that distinction with a nullable preference interface. Seven existing JVM cases and two supplemental cases passed against the pinned implementation. The providers and account state were synthetic. This chapter follows the registrar’s decision order and the selected app integration, while keeping Android permission and delivery acceptance separate.
Represent false as a known value rather than a missing value
The selected preference has three states: true, false and null. A stored false is an explicit value. It should reach the server unchanged rather than fall through to a default. The existing persisted-preference case asserts that registration sends false without fetching a replacement profile value.
The inspected AppContainer adapter checks whether the SharedPreferences key exists before reading its Boolean. An absent key therefore becomes null. That source connection matters because simply supplying a Boolean read default could erase the distinction. The JVM cases use an in-memory adapter; they do not exercise storage durability, actual Android lifecycle restoration or a migration from an older installed preference format.
Fetch an unknown preference without guessing when offline
When no explicit settings override or stored value exists, the registrar invokes its profile-preference dependency. An existing case returns false, verifies that value is persisted and checks the outgoing registration body. Another throws an offline exception and verifies that registration returns false without sending a guessed preference.
This is a deliberately different outcome from a known opt-out. The application has insufficient information to register in the selected branch; it has not established that the user enabled or disabled notifications. Product handling should retain that distinction when deciding whether to retry, refresh profile data or show a settings state. A transient failure should not manufacture a new preference.
Treat a settings override and server acceptance as separate steps
An explicit override is stored before the selected send dependency executes. The existing settings case passes false over an earlier true and checks both persistence and the transmitted field. A supplemental case then makes the first send throw and the next send succeed while preserving the stored false across both attempts.
The registrar’s registered flag follows acceptance of that send callback. It remains false after the selected failure and becomes true after the later accepted attempt. This flag is not proof that the operating system allowed notifications or that a provider delivered anything. The inspected AppContainer callback also invokes live-update and teleconsult token hooks; their complete behaviour was not executed by these registrar fixtures.
Stop early when the selected provider is unavailable
The supplemental unavailable-backend case supplies dependencies that fail if preference fetching, token acquisition or registration is attempted. The registrar returns false without invoking those dependencies. This distinguishes an unavailable provider path from a profile-fetch failure or a rejected server registration.
The backend interface exposes availability, token acquisition and token deletion as separate operations. Those operations are convenient isolation points for testing, but their fake outcomes do not establish Firebase configuration, a build variant’s installed capabilities or recovery from a real provider error. Those require a separate build and device acceptance package with the intended backend and permissions.
Clear account preference and retry provider deletion within the scope
The selected deletion entry point marks the registrar unregistered and clears its preference, then reuses an already active deletion job or launches one. The existing retry case makes deletion fail three times before succeeding on the fourth call and checks that the account preference is cleared. Virtual scheduling keeps that fixture deterministic.
The source’s default delays rise from one second through five minutes, then reuse the final delay. The loop has no fixed attempt count, but it runs inside the supplied coroutine scope. That is an in-process retry policy. It does not establish a persistent background job, survival across process death or eventual provider completion. Describe the scope and cancellation conditions alongside any retry promise.
Verify a selected deletion-before-registration ordering
Before entering its registration mutex, the registrar waits for the recorded deletion job. The existing ordering case starts a deletion that fails twice, then requests registration and checks that the send observes three completed delete calls. This is useful evidence for one controlled overlap between an old-token cleanup and registration.
It is not an exhaustive proof for every coroutine interleaving, simultaneous entry or app restart. A mutex and a passing ordering fixture should be described at their actual scope. Extend acceptance with deliberately controlled start/cancel/rotation schedules, including changes of account, before claiming that all token races are resolved. Keep provider and authoritative account state in those acceptance expectations.
Gate incoming pushes independently of token registration
One of the seven existing cases exercises PushRouter with a mutable signed-in predicate. A signed-out message is dropped without showing a notification or requesting refresh. The same synthetic message is handled after the predicate becomes signed in. This tests a local routing decision independently of the registration lifecycle.
The inspected AppContainer source guards token rotation and registration with session state and cancels notifications during account-data wiping before scheduling provider deletion. Those source paths were not mounted in an Android process here. A router predicate does not independently authorize a clinical record, clear every already displayed OS surface or prevent a provider from sending an already queued message.
An acceptance package for account-safe notification plumbing
Keep the nine scoped cases with their source hashes, then test the actual preference adapter and signed-in integration under account changes, provider unavailability and process recreation. Exercise Android permission denial, a real token rotation and logout with controlled test accounts. Verify authoritative token ownership and what the user actually sees on the device.
For a CTO, the useful handover is a state model: known choice, unknown choice, registration accepted, deletion pending and session ended are separate facts. This model makes retry and recovery reviewable. The selected local cases establish concrete transitions without turning an accepted fake send into a delivery guarantee or an in-process loop into durable cleanup.
Compare the reviewed boundaries
Notification registration carries several independent states
On smaller screens, scroll across to compare every column. Keyboard users can focus the table and use the arrow keys.
| State | Selected evidence | Additional acceptance |
|---|---|---|
| Known opt-out | False preserved through registration and retry | Actual preference storage and account transitions |
| Unknown choice | Fetch failure refuses guessed registration | Profile service and recovery UX |
| Deletion pending | Four-attempt fixture and one ordering case | Process death, cancellation and provider behaviour |
| Signed out | Synthetic router drops show/refresh | OS surfaces and authoritative record access |
Illustrative control flow
Pseudocode summarizing the decision boundary. It is not copied production code or a deployment instruction.
if provider_unavailable: return unregistered
await recorded_pending_deletion
choice = explicit_override ?? stored_choice ?? fetch_profile_choice()
if choice_unknown: return unregistered
registered = attempt_registration(token, choice)
# Provider deletion retry is scoped to this process/coroutine lifetime.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 ↗