# User data

User will be registered anonymously right after SDK initialization and currently tracked User context will be stored on a device. To set specific user attributes, pass them using UserComSDK.instance.register() function.


# Set User Data

To pass User Data, call User.com SDK instance and pass Customer object as an attribute. Customer class is provided by flutter_user_sdk and allows to update Standard and Custom attributes.

INFO

All attributes should have simple values. Read more about User Attributes in User.com Docs. (opens new window)

You can add any number of Custom attributes, or use Standard attributes and combine them. Sending data using this method will update currently tracked User with all the attributes specified or switch tracking when User already exists in User.com.

  • Dart
UserComSDK.instance.registerUser(
    customer: Customer(
        userId: 'my_own_id_3',
        email: 'my_own_user@gmail.com',
        gender: 2,
        firstName: 'Test',
        lastName: 'User',
        phoneNumber: '+1234567890',
        score: 100,
        unsubscribed: true,
    )
    ..addCustomAttribute('country', 'USA')
    ..addCustomAttribute('has_benefits', true)
    ..addCustomAttribute('nick', 'freddy')
    ..addCustomAttribute('age', 22),
);

# Authentication

Table below explains User Authentication rules when sending values for specific Attributes.

Attribute User.com name Description
userId User ID When there is no User with this User ID, tracking will continue on the current User. When there is a User with this User ID, tracking will switch to the already existing User
email Email Email value is not used to authenticate User. It will always update currently tracked User
other attributes - Not used for authentication

Use your own userID to make sure Users are identified consistently on all devices.


# Logout

To logout and clear all user-related resources within SDK only and prevent from receiving push messages, invoke:

UserCom.instance.logout();

Calling this method will create a new Anonymous User and attach FCM Token.

INFO

If you call register() method after logout, you can still send Events to same user. Just pass userId of a User you want to track.