Skip to main content

Overview

Encore requires user identification to track entitlements and prevent abuse across devices. You can also set user attributes to enable targeted offers and personalization.

Anonymous Users

Encore automatically generates a random user ID that persists until the user deletes/reinstalls your app or calls reset(). This anonymous ID allows entitlement tracking to work immediately without requiring explicit user identification.

Identified Users

If you use your own user management system, call identify() when you have a user’s identity:
await Encore.identify(user.id);
This enables the SDK to:
  • Associate promotional access with your user account
  • Sync entitlements across devices when the user logs in
  • Track conversion attribution accurately

Resetting User Identity

When a user logs out, call reset():
await Encore.reset();
This will:
  • Reset the user ID to a new auto-generated anonymous ID
  • Clear cached entitlement data
  • Clear all user attributes

Setting User Attributes

User attributes enable personalized offers, audience targeting, and conversion context tracking.

Usage

await Encore.setUserAttributes({
  email: 'user@example.com',
  subscriptionTier: 'premium',
  monthsSubscribed: '6',
  custom: {
    cancelReason: 'too_expensive',
  },
});
You can also set attributes when identifying:
await Encore.identify(user.id, {
  email: user.email,
  subscriptionTier: user.plan,
  monthsSubscribed: String(user.monthsActive),
});
Important: setUserAttributes() merges with existing attributes — it does not replace them.
See the SDK Reference for details: identify(), setUserAttributes(), and the full UserAttributes field list.

Implementation Examples

With useEncoreContext Hook

import { useEncoreContext } from '@tryencorekit/react-native';

function ProfileScreen() {
  const encore = useEncoreContext();

  const handleLogin = async (user) => {
    await encore.identify(user.id, {
      email: user.email,
      subscriptionTier: user.plan,
    });
  };

  const handleLogout = async () => {
    await encore.reset();
  };

  return (
    // ...
  );
}

Apps Without Login

If your app doesn’t require users to log in, no additional setup is needed:
// Anonymous users work automatically — just set attributes if needed
await Encore.setUserAttributes({
  custom: { cancelReason: 'too_expensive' },
});

Next Steps

  • Present Offers - Show promotional offers and handle purchase results