Skip to main content

Cross-Device Consent & User Reset

This page covers how to associate consent with an external user, the account prerequisite that makes cross-device features work, and the officially supported way to reset or switch users — so you never need the hacky workaround of re-initializing the ConsentManager with empty values.

External user ID (extUsrData)​

setExtUsrData associates an external user identifier with the consent record. Provide the same ID across devices and platforms (e.g. web and mobile) and the SDK can look up and apply that user's existing consent, keeping consent consistent across environments.

val manager = ConsentManager.Builder(context)
.setCustomerId("my_customer_id")
.setConfigId("my_config_id")
.setConsentingDomain("my.domain.com")
.setExtUsrData("my_user_id")
.build()

The consent record is stored per external user on the device, so each extUsrData value has its own consent state.

Prerequisite: Cross-Device Consent must be enabled on your account

Setting an external user ID and looking up or searching users across devices requires Cross-Device Consent (CDC) to be enabled on your Osano account. CDC is an opt-in capability, available on Premier plans, that Osano enables per configuration.

If CDC is not enabled, external-user-ID features will not behave as documented. The SDK gates every cross-device lookup on the remoteConsent flag delivered in your configuration; when CDC is off this flag is false, so the lookup does not run. Calls may silently fail, return empty results, or appear to have no effect, which can look like a bug during implementation or troubleshooting.

To enable Cross-Device Consent, contact your Customer Success Manager or Osano Support.

Switching to a different user​

The external user ID is set on the builder, so to switch users, build a new ConsentManager with the new ID. Set it to an empty/null value to fall back to the anonymous (device-scoped) record — the equivalent of "logging out."

val manager = ConsentManager.Builder(context)
.setCustomerId("my_customer_id")
.setConfigId("my_config_id")
.setExtUsrData("new_user_id") // switch user
.build()

Use the built-in API rather than clearing SharedPreferences manually:

manager.clearConsent()   // clears the current user's stored consent
danger
clearPreferencesForDebug() is for debugging only

clearPreferencesForDebug() wipes all of the SDK's local SharedPreferences and caches. It is explicitly for debugging and must not be used as a production reset path. For production, use clearConsent() and re-build the manager with the desired extUsrData.

Full reset (e.g. on logout)​

To fully reset user data, clear the current user's consent and then rebuild the manager without an external user ID. This is the officially supported alternative to re-initializing with empty values:

manager.clearConsent()   // drop this user's stored consent

// Rebuild anonymous — no setExtUsrData() → device-scoped record
val anonymous = ConsentManager.Builder(context)
.setCustomerId("my_customer_id")
.setConfigId("my_config_id")
.build()

Troubleshooting cross-device lookups​

If setting extUsrData and expecting an existing consent record to load has no effect:

  1. Confirm Cross-Device Consent is enabled on your account/configuration (see the prerequisite above). This is the most common cause — without it, remoteConsent is false and the lookup never runs.
  2. Confirm the same extUsrData value is used on the other device/platform (web and mobile hash the identifier identically, so it must match exactly).
  3. Confirm the manager finished initializing before you read consent.