setDeviceToken
Stores token as the device token only if the stored token still equals expected.
Intended for framework integrations whose own runtime shares this client: pass the token the integration's request was sent with as expected so a stale response cannot overwrite a newer token. A null or blank expected means no token is stored, and a null token deletes the stored token.
A rotation of the same client's token is cheap: no network request and no client refresh. When the token is cleared or now belongs to a different client, the in-memory client, session and token caches are dropped and a client refresh is started in the background so native state follows the new token.
Return
true if the stored token matched expected and now equals token; false otherwise (including when Clerk is not initialized), in which case the stored token is left unchanged.
Parameters
The non-blank device token to store, or null to delete the stored token.
The device token the caller expects to be stored, or null for none.
Throws
if token is blank.