# Register a user

User will be registered anonymously right after SDK initialization. To set specific user attributes, pass them using FutterUserSDK.instance.register(…) function. Usually, we are registering the client's information during Login activity when the client passes some data in forms.

To trigger register action, call UserComSDK instance and pass Customer Object as attribute. Customer class is provided by flutter_user_sdk and has predefined attributes. You can also add Your own. Note that addCustomAttribute(...) should have simple values.

UserComSDK.instance.registerUser(
  customer: Customer(
    userId: 'my_own_id_2',
    email: 'my_own_user@gmail.com',
    firstName: 'Test',
    lastName: 'User',
  )
    ..addCustomAttribute('country', 'USA')
    ..addCustomAttribute('has_benefits', true)
    ..addCustomAttribute('sex', 'female')
    ..addCustomAttribute('age', 22),
);

This will create a user in User.com with all the attributes you specify, or log in an existing one if data matches the record in User.com database.

You can add any number of custom customer attributes, or use predefined ones and combine them.

Logout

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

UserCom.instance.logout();

Note that if You call register(...) method after logout, You can still report events to same user. Just pass id of user You want to track.