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)
extUsrData 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.
let consentManager = ConsentManager(customerId: "my_customer_id",
configId: "my_config_id",
consentingDomain: "my.domain.com",
extUsrData: "my_user_id")
The consent record is stored per external user on the device, so each extUsrData value has its
own consent state.
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
You do not need to re-create the ConsentManager. Assign a new value to extUsrData; the SDK
refreshes the user context and reloads consent for that user automatically. Set it to nil to revert
to the anonymous (device-scoped) record — the equivalent of "logging out."
consentManager.extUsrData = "new_user_id" // switch user — reloads that user's consent
consentManager.extUsrData = nil // revert to anonymous / log out
Resetting or clearing consent
Use the built-in APIs rather than clearing storage manually:
consentManager.clearConsent() // clears the CURRENT user's consent only
consentManager.clearAllUsersConsent() // full reset across ALL users — use with caution
consentManager.clearConsentIfInvalid() // clears only an expired/invalidated record (no-op otherwise)
clearConsent()— removes the stored consent for the activeextUsrData(or the anonymous record if none is set).clearAllUsersConsent()— wipes every stored user's consent for a full local reset. Use with care.clearConsentIfInvalid()— clears the record only if it has expired or been invalidated (e.g. force-reconsent); returns whether anything was cleared.
Full reset (e.g. on logout)
To fully reset user data, clear the current user's consent and then drop the external user ID. This is
the officially supported alternative to re-creating the ConsentManager with empty values:
consentManager.clearConsent() // drop this user's stored consent
consentManager.extUsrData = nil // drop the user — revert to anonymous / device-scoped
Troubleshooting cross-device lookups
If setting extUsrData and expecting an existing consent record to load has no effect:
- Confirm Cross-Device Consent is enabled on your account/configuration (see the prerequisite
above). This is the most common cause — without it,
remoteConsentisfalseand the lookup never runs. - Confirm the same
extUsrDatavalue is used on the other device/platform (web and mobile hash the identifier identically, so it must match exactly). - Confirm the manager finished initializing before you read consent.