# Register a user

To register a user you can either send information about the user, or create a new anonymous user without providing any data. Usually you send information about a user when he's logging into the app or registering - that's when the user passes some data in forms - but before that you might want to create a new user just to gather information about user's events and screen views.

Registering anonymous user

To register anonymous user use ping() method - it will create a user if no attributes were set before.

  • Swift
  • Objective C
To initialize User.com SDK, you need to add the following line of code to the top of your AppDelegate.swift file:

Set standard and custom attributes

You can add any number of custom customer attributes, or use predefined standard attributes

  • Swift
  • Objective C
    UserSDK.UserDataKey.firstName : "Test",
    UserSDK.UserDataKey.lastName : "User",
    UserSDK.UserDataKey.email : "test@user.com",
    UserSDK.UserDataKey.phone : "+1222333444",
    UserSDK.UserDataKey.userId : "yourcustomerid"

    "custom attribute name" : "custom attribute value"


To logout and clear all user-related resources within SDK, invoke:

  • Swift
  • Objective C