React Native
Learn how to import Adapty React Native SDK in your app, configure it, and set up logging
To initialize Adapty SDK, import activateAdapty
function and call it in a core component, such as App.tsx
. Wrap this function with a useEffect
hook to make sure Adapty initializes only once.
import { activateAdapty } from 'react-native-adapty';
const App: React.FC = () => {
// ...
useEffect(() => {
activateAdapty({ sdkKey: 'PUBLIC_SDK_KEY' });
}, []);
// ...
}
activateAdapty
has several more parameters:
sdkKey
— Public SDK key**. Required. Can be found in your app settings in Adapty DashboardApp settings
>General
customerUserId
— Customer user ID. Optional. An identifier of the user in your system. We send it in subscription and analytical events, to attribute events to the right profile. You can also find customers bycustomerUserId
in the Profiles sectionobserverMode
— Observer mode. Optional. Default isfalse
. Controls Observer mode. Turn it on if you handle purchases and subscription status yourself and use Adapty for sending subscription events and analyticslogLevel
— Debugging log level. Optional. Default is'none'
. Adapty logs errors and other important information to help you understand what is going on. Possible values are'verbose'
,'errors'
or'none'
. If on, errors are displayed within platform-specific IDE (Xcode or Android Studio)
activateAdapty({
sdkKey: 'PUBLIC_SDK_KEY', // string
customerUserId: 'YOUR_USER_ID', // string | undefined
observerMode: true, // boolean
logLevel: "verbose", // 'verbose' | 'errors' | 'none'
});
Make sure you use the Public SDK key for Adapty initialization, the Secret key should be used for server-side API only.
SDK keys are unique for every app, so if you have multiple apps make sure you choose the right one.
Updated 7 months ago
Did this page help you?