change User
When a user first uses Braze on a device they are considered "anonymous". Use this method to identify a user with a unique ID, which enables the following:
If the same user is identified on another device, their user profile, usage history and event history will be shared across devices.
If your app is used on the same device by multiple people, you can assign each of them a unique identifier to track them separately. Only the most recent user on a particular device will receive push notifications and in-app messages.
When you request a user switch (which is any call to changeUser where the new user ID is not the same as the existing user ID), the current session for the previous user (anonymous or not) is automatically ended and a new session is started. Similarly, following a call to changeUser, any events which fire are guaranteed to be for the new user -- if an in-flight server request completes for the old user after the user switch no events will fire, so you do not need to worry about filtering out events from Braze for old users.
Additionally, if you identify a user which has never been identified on another device, the entire history of that user as an "anonymous" user on this device will be preserved and associated with the newly identified user. However, if you identify a user which has been identified in another device, any history which was already flushed to the server for the anonymous user on this device will be merged into the identified user.
Parameters
An external user identifier. May not be longer than Constants.USER_ID_MAX_LENGTH_BYTES.
See also
Note: Once you identify a user, you cannot revert to the "anonymous" user. The transition from anonymous to identified tracking is only allowed once because the initial anonymous user receives special treatment to allow for preservation of their history. As a result, we recommend against changing the user ID just because your app has entered a "logged out" state because it makes you unable to target the previously logged out user with re-engagement campaigns. If you anticipate multiple users on the same device, but only want to target one of them when your app is in a logged out state, we recommend separately keeping track of the user ID you want to target while logged out and switching back to that user ID as part of your app's logout process.
Note that a BrazeUser can be retrieved at any time using IBraze.getCurrentUser.
Identical to .changeUser but provides an sdk auth signature for the user before any networking begins, even if the existing external id is used.
See also
.changeUser