Xee Docs
Get started

Identify users on Android

View as Markdown

Xee keeps a profile for every person using your app. If your app has accounts, give Xee your own user ID, so the person's access follows them to any device they sign in on, Android or iOS.

Profiles and customer user IDs

  • The SDK creates a profile on activation. You never create one yourself.
  • A profile is anonymous until it has a customer user ID: your own ID for the person, from your login system.
  • One customer user ID belongs to one profile in an app, on both stores. Xee never moves an ID from one profile to another.
AnonymousIdentified
ProfileA new one on each installOne per customer user ID
PurchasesBelong to this install's profileBelong to the profile that follows the customer user ID
Other devicesNo access thereAccess on every device signed in with the ID, iOS included

Every profile has an account token, a UUID the SDK keeps on the device. The SDK passes it to Google with each purchase as obfuscatedAccountId, and Google repeats it in everything it says about the purchase. Xee then picks the first of these that applies:

  1. The profile whose token the purchase carries.
  2. The profile the subscription already belongs to. A later notification keeps it where it is.
  3. The profile that reported it, with makePurchase, restorePurchases or reportPurchase.

A subscription never moves away from a profile that owns it. A purchase made without Xee carries no token: it attaches to the profile that restores it.

Identify at activation

If the person is signed in when the app starts, pass their ID to activate. The SDK then creates the profile with that ID, without an anonymous profile first.

kotlin
val config = XeeConfig.Builder("YOUR_SDK_KEY")
    .customerUserId("customer-1")
    .build()
Xee.activate(context, config)

customer-1 stands for the value from your own account system. Never hardcode it: every install would share one profile.

Identify after login, and log out

When the person signs in or signs up after the app has started, call identify. When they sign out, call logout:

kotlin
Xee.identify("customer-1")
// ... and when the person signs out:
Xee.logout()

What identify does depends on the ID:

  • An ID Xee has not seen: it is attached to the current anonymous profile, which becomes the customer's profile.
  • An ID that already belongs to another profile: the device switches to that profile, the one the customer has on their other devices. Anything the anonymous profile bought stays on it, and is not merged.

Wait for identify to return before other Xee calls: it returns the profile the device is now on. logout starts a new anonymous profile on this device, and returns it.

Add facts about the person

kotlin
Xee.updateProfile(XeeProfileParameters(email = "a@example.com"))

XeeProfileParameters also takes phoneNumber, firstName, lastName, gender and birthday. Each one you leave out stays as it is.

People on several devices

Your setupWhat happens
Customer user ID passed at activation, on a fresh installThe device gets the person's existing profile, or a new one with the ID.
identify after login, with an ID Xee has not seenThe anonymous profile becomes the customer's profile.
identify after login, with an ID that already has a profileThe device switches to that profile.
The same ID on iOS and AndroidOne profile: access bought on either store unlocks both.
No login at allProfiles stay anonymous. Access does not follow the person to another device; Restore brings it back on the same Google account.

Keep a Restore button on your paywall anyway. See Make purchases.