React Native - Identifying Users
Important
Custom User Identifiers
Adapty creates an internal profile id for every user. In case you're an in-house authentification system, you would want to set your own Customer User ID.
You can find the users by Customer User ID in Profiles, use it in server-side API, it will be sent to all integrations.
Setting customer User Id on configuration
If you have a user id during configuration, 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 customer user Id after configuration
If you don't have a user id on SDK configuration, you can set it later at any time with .identify()
method. The most common cases are after registration/authorization when the user switches from being an anonymous user to an authenticated user.
try {
await adapty.profile.identify("YOUR_USER_ID");
} catch (error: AdaptyError) {}
Request parameters:
- User ID (required): a string user identifier.
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 log in the user using .identify()
method.
Updated 10 months ago