Mobile SDK Identity Management, Consent & Working with Web-Views

Identity management

User Consent

The SDK stores user and session identifiers locally on the device to enhance functionality. It's your responsibility to ensure compliance with relevant data protection regulations, including obtaining any necessary user consent for data collection, storage, and processing, as required by law.

Resetting the Mobile SDK identifiers

The Mobile SDK manages the user ID (dyid) and session ID (sessionId) behind the scenes.

If the app manages multiple logged-in users, with every switch between users reset the user ID using the resetUserIdAndSessionId() function before firing the logging event, as an anonymous identifier (dyid) can be linked to only one identified user identifier (cuid). To reset only one identifier, use resetUserId() or resetSessionId().

If the native app is intended to be installed on a device that isn't private (on-site assistant), we recommend using the resetUserIdAndSessionId() function with every new flow supported by the app.

Note: If the native app intends to serve a Kiosk and ODMB (Restaurant sections), there is no need to reset the identifiers. Be sure to set the SharedDeviceflag as true when initializing the SDK.

Using the SDK with WebView

To correctly implement Dynamic Yield (using Experience API or script) within WebView, you must pass the dyId and sessionId parameters from the application’s native code to WebView. If you don't, new user and session identifiers are created, which result in an inflated number of users and erroneous reports. To retrieve the needed values, call the getDyId() and the getSessionId() methods:

var dyId = DYSdk.getInstance().getDyId()  
var sessionId = DYSdk.getInstance().getSessionId() 
 var dyId = DYSdk.shared().getDyId()
 var sessionId = DYSdk.shared().getSessionId()
import { getDyId, getSessionId } from '@dynamicyield/react-native-sdk'
const dyId = getDyId();
const sessionId = getSessionId();

If you've implemented Experience API campaigns in WebView, pass the values in the WebView URL when making the calls to your server. If you've implemented Experience API on the client-side, make sure to include them as part of the response to WebView itself (as cookies or other framework). When choosing a variation or reporting engagement or events, pass the user ID in the user.dyid and user.dyid_server attributes, and the session ID in the session.dy attribute. These are the same attributes the SDK sends.

If you're using the Dynamic Yield script within WebView, add the values to the WebView URL and set them as cookies from the server in the response: the user ID as the _dyid_server cookie and the session ID as the _dyjsession cookie. The cookies are automatically consumed by the script.

Note: If you use active consent (activeConsentIntegration is true) and the user hasn't accepted, the SDK doesn't store a user ID or session ID, so there are no values to pass to the WebView. Pass them only after the user accepts.


Did this page help you?