Identifying users

Learn how to identify users of your app using Adapty React Native SDK. Identified users have access to subscriptions across all available platforms: iOS, Android, web

Adapty creates an internal profile id for an every user. However, if you have your auth system you should set your own CustomerUserId. You can find a user via CustomerUserId in Profiles, use it in a server-side API, it will be sent to all integrations.

Setting CustomerUserId

If you have a user id while app init, just pass it as customerUserId parameter to .activate() method:

import { activateAdapty } from 'react-native-adapty';

const App: React.FC = () => {
  ...
  useEffect(() => {
    activateAdapty({ 
      sdkKey: 'PUBLIC_SDK_KEY',
      customerUserId: 'YOUR_USER_ID',
    });
  },[]);
  ...
}

Setting CustomerUserId after the init

If you don't have a user id while app initialises, you can set it later at any time with profile.identify() method. The most common cases are after registration/auth, when a user switches from being an anonymous user to an authenticated user.

try {
    await adapty.profile.identify("YOUR_USER_ID");
} catch (error: AdaptyError) {}

Logging out and logging in

You can logout the user anytime by calling .logout() method:

try {
    adapty.profile.logout();
} catch (error: AdaptyError)

You can then login the user using .identify() method.


Did this page help you?