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 thisunique 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
MoEngageSDKAnalytics.sharedInstance.setUniqueID(UNIQUE_ID) // UNIQUE_ID is used to uniquely identify a user.
[[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
|
Logout
MoEngageSDKAnalytics.sharedInstance.resetUser()
[[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:
MoEngageSDKAnalytics.sharedInstance.setAlias(UPDATED_UNIQUE_ID)
[[MoEngageSDKAnalytics sharedInstance] setAlias:UPDATED_UNIQUE_ID];