Setting Unique Id for SDK versions below 9.23.0

User Login / Logout

It is important that you handle user login and logout as mentioned below. There is a definite possibility that your data gets corrupted if this is not done properly.

  • Make sure to get hold of a unique id for your app users and pass that information to our SDK using the setUniqueID(_:) method. We use this unique id to identify a user and also to merge user profiles across installs and platforms.
  • And also, once the user logs out of your app, it is necessary to call resetUser() of SDK so that we create a new anonymous user and track the events following this to the new user's profile.

Kindly ensure you call the following methods on user login/logout.

Login

Swift Objective-C
MoEngageSDKAnalytics.sharedInstance.setUniqueID(UNIQUE_ID) // UNIQUE_ID is used to uniquely identify a user.

Note: The following values are not allowed in the UniqueID field: "unknown", "guest", "null", "0", "1", "true", "false", "user_attribute_unique_id", "(empty)", "na", "n/a", "", "dummy_seller_code", "user_id", "id", "customer_id", "uid", "userid", "none", "-2", "-1", "2"

warning

UNIQUE ID chaos

  • When you go live with MoEngage iOS SDK for the first time, please ensure that you are setting the Unique ID of the already logged-in user along with other user attributes.
  • Kindly make sure that you are not using a single unique id for all the users, this can happen if you hard code the value, instead of fetching it from your servers.
  • If you pass 2 different unique id information without calling resetUser() method in between, the SDK will internally force logout the existing user.

Logout

Swift Objective-C
MoEngageSDKAnalytics.sharedInstance.resetUser()

Updating User Attribute Unique ID

warning

Important

Please make sure that you use setAlias(_:) for updating the User Attribute Unique ID and not setUniqueID(_:) as calling setUniqueID(_:) with a new value will reset the current user and lead to the creation of unintended users in our system.

In a scenario where you have to update the existing user's Unique ID value make use of setAlias(_:) method as shown below with the updated Unique ID value:

Swift Objective-C
MoEngageSDKAnalytics.sharedInstance.setAlias(UPDATED_UNIQUE_ID)

Previous

Next

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?