# Contact Data

Right after SDK initialization, an anonymous contact is created in Positive User. Tracking continues on the same contact on subsequent app launches.


# Identify a contact

Call register() with a Customer object to attach identity to the current contact. Best called from your login flow, once you have the contact's data.

  • Kotlin
  • Java
val customer = Customer()
    .id("your-internal-user-id")
    .firstName("Jane")
    .lastName("Doe")
    .email("jane@example.com")
    .attr("plan", "pro")
    .attr("loyalCustomer", true)
    .attr("age", 33)

UserCom.getInstance().register(customer, object : CustomerUpdateCallback {
    override fun onSuccess(response: RegisterResponse) {
        // contact identified - you can now send events
    }

    override fun onFailure(throwable: Throwable) {
        // something went wrong - try again
    }
})

# Standard attributes

Method Field sent Type
.id(String) user_id String
.firstName(String) first_name String
.lastName(String) last_name String
.email(String) email String

# Custom attributes

Use .attr() to send any additional attributes:

.attr("attributeName", "string value")
.attr("attributeName", true)       // boolean
.attr("attributeName", 42)         // integer

# Authentication behavior

Attribute Behavior
.id() If a contact with this ID exists, tracking switches to that contact. If not, the current contact gets this ID.
.email() Always updates the current contact - not used for authentication.
Other attributes Always update the current contact.

# Start with an identified contact

To skip the anonymous contact phase entirely, pass a Customer to the builder during initialization:

  • Kotlin
  • Java
UserCom.Builder(this, sdkKey, apiKey, domain)
    .setDefaultCustomer(Customer().id("your-user-id").email("jane@example.com"))
    .build()

# Get the Positive User contact key

RegisterResponse contains the internal Positive User identifier for the current contact (user_key). Use it for custom API requests.

  • Kotlin
  • Java
UserCom.getInstance().register(Customer(), object : CustomerUpdateCallback {
    override fun onSuccess(response: RegisterResponse) {
        val userKey = response.key
    }
    override fun onFailure(throwable: Throwable) {}
})

# Logout

Call logout() to clear all contact data and start a new anonymous session:

  • Kotlin
  • Java
UserCom.getInstance().logout()

Detaches the FCM token and switches to a new anonymous contact.