Sign out and switch consumers
Guides

Sign out and switch consumers

Stop the payment screen and call clear when the consumer signs out. On iOS, first call await bleClient.stop() if you use the separate Bluetooth client. Wait for success and handle local storage errors before treating SDK cleanup as complete.

sdk.clear()
sdk.onboarding.clearRegistration() // Also abandon any separate OTP registration flow.

clearRegistration is a separate call because ordinary sign-out does not clear the in-memory registration OTP state.

What a successful clear removes

StateAndroidiOS
Consumer sessionDeletedDeleted from Keychain
Saved wallet recovery operationDeletedDeleted from Keychain
Hosted form presentation and storageClosed; form-origin Web Storage clearedClosed; non-persistent data store replaced
Native consumer payment keysDeleted; NFC disarmedAccount-key vault deleted
Separate iOS Bluetooth clientNot applicableYour app must stop it; clear does not own this client

clear makes no API call. It does not revoke server sessions, reverse wallet activation or remove server-side device associations.

What your app still owns

clear leaves your app's storage, developer signing key, local device identity, current in-memory FCM token and registration OTP state alone. Clear your own consumer-specific UI and storage as part of sign-out. Use clearRegistration when abandoning registration, and manage developer-key removal separately during rotation.

Handle incomplete cleanup

A storage error can stop cleanup. On iOS, consumer payment keys are deleted first, then form storage, the saved wallet operation and the session. If key deletion throws, later cleanup is not reached. If saved-operation deletion throws, session deletion is not reached. Do not assume every deletion was attempted.

On failure, keep protected actions unavailable, show a cleanup error and offer a retry. Do not log tokens or key material when reporting it.

Sign-out during login

On Android, clear waits for the lock held by login; it does not immediately cancel a browser login. Prevent overlapping sign-in actions and finish or cancel the active login flow first.

On iOS, clear can finish while login is waiting. That superseded login fails with VALIDATION. See Consumer sessions.

Switch consumers

A successful login or applySession for another consumer replaces the session and clears the previous consumer's form and recovery state. Both platforms remove previous native payment keys. On iOS, stop the separate Bluetooth client first. On iOS, hosted login saves the new session before payment-key cleanup, so a cleanup failure can occur after that session was installed. Android invalidates the previous payment keys before writing a replacement session. Protected API work still using the old session is rejected with VALIDATION.

Calling clear first is useful when your UI has an explicit sign-out step. Always clear your own cached account data when switching.

After a password change or device compromise

A successful password change invalidates the session; sign in again. On DEVICE_COMPROMISED, stop protected work and show a device error instead of restarting login.

Merchant sign-out

POS has a different cleanup contract: clear() removes merchant credentials/context/key but retains its financial journal. See Merchant sessions and terminals.