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 with empty values.
External user ID (extUsrData)
The extUsrData prop 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.
<Osano
customerId="my_customer_id"
configId="my_config_id"
extUsrData="my_user_id"
>
{/* your app */}
</Osano>
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
Change the extUsrData prop passed to <Osano>. The provider re-creates the consent manager for the
new user and loads that user's consent. Pass an empty string to fall back to the anonymous
(device-scoped) record — the equivalent of "logging out."
<Osano customerId="my_customer_id" configId="my_config_id" extUsrData={currentUserId}>
{/* extUsrData="" reverts to anonymous */}
</Osano>
Resetting or clearing consent
clearConsent is exposed through the Osano context. Read it from OsanoContext and call it to clear
the current user's stored consent:
import { useContext } from 'react';
import { OsanoContext } from '@osano/osano-cmp-react-native';
const { clearConsent } = useContext(OsanoContext);
// later, e.g. on logout:
clearConsent();
This resets the stored consent for the active user back to essential-only. To reset and switch users
at the same time, call clearConsent() and change the extUsrData prop.
Full reset (e.g. on logout)
To fully reset user data, clear the current user's consent and then drop the external user ID by
setting the extUsrData prop to an empty string. This is the officially supported alternative to
re-initializing with empty values:
// 1. Clear the current user's stored consent
const { clearConsent } = useContext(OsanoContext);
clearConsent();
// 2. Drop the user — render <Osano> with an empty extUsrData (anonymous / device-scoped)
<Osano customerId="my_customer_id" configId="my_config_id" extUsrData="">
{/* your app */}
</Osano>
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 provider has finished loading the configuration before you read consent.