Set User ID

Link a device profile to an identified user profile

A device profile can be linked to an identified user profile if your SDK integration provides a unique identifier known as the User ID. This can be useful to allow integration with your own CRM backend. At the point where the customer is identifiable and their customer ID is available the ID can be set. This is often at sign-in in the mobile app or on the website. The SDK methods are shown below:

XPush.setUser("CUSTOMER_ID")
[XPush setUser:@"CUSTOMER_ID"];
mPushConnector.setUser("CUSTOMER_ID");
xtremepush('set', 'user_id', 'CUSTOMER_ID');
DependencyService.Get<IXPushDelegate>().SetUser("CUSTOMER_ID");
Alloy.Globals.xtremepush.setUser("CUSTOMER_ID");
XtremePush.setUser('CUSTOMER_ID')

Association behaviour

Every device profile is connected to an anonymous user profile by default.

When setting the User ID:

  • If the User ID does not already exist in the Xtremepush project, the current anonymous user profile will become identified by the User ID, maintaining any existing attributes and message/event history.
  • If the User ID already exists on another user profile, the device profile will be re-associated to the identified user profile with the matching User ID. Any attributes or message/event history on the anonymous profile will be lost.
  • If setting the User ID to an empty value, the device profile will be re-associated to a new anonymous profile, leaving the previous identified profile intact.

👍

Set User ID first

Because the device may be re-associated to a different user profile, it is usually recommended to set the User ID before setting attributes or firing events to trigger campaigns, so the identified user profile is used.