Last updated
Last updated
When launching a Preference Center from a mobile app, the user is taken from your app to the Preference Center running in WebView. While the user is authenticated in your mobile app, this authentication gets lost when the Preference Center is loaded.
To launch a Preference Center from a mobile app and pass the user authentication information, you will need to:
Create a consent token for your Preference Center in your app backend
Launch your preference center in a WebView
A consent token is generated by sending an API request to the Didomi API that includes the user information (in particular, the organization user ID).
To create a consent token, send an HTTP POST request to the Didomi API:
Read more about and .
As the private API key must remain private, your app must first call you app backend in an authenticated context and your app backend can then call the Didomi API:
Once you have obtained a consent token, you can generate an authenticated URL to the Preference Center by adding the consent token to the Preference Center URL in a token
query-string parameter.
We recommend that your backend returns the full authenticated URL with the token so that your app can simply launch that URL and does not hardcode any part of the URL.
The createPreferenceCenterURL
Cloud Function will return the authenticated Preference Center URL with the user email from Firebase Authentication. It requires users to be authenticated via Firebase Authentication.
Once you have obtained an authenticated URL to the Preference Center, simply open it in a WebView or in the device browser.
Example:
If your app is using Firebase, you can easily create an authenticated URL via a . We provide a Cloud Function to create a Preference Center URL that can be deployed to your Firebase account:
You then can with:
How to launch a Preference Center from a mobile app