Configuration

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 useEffect(callback,[]) 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 Dashboard App settings > General
  • customerUserIdCustomer 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 by customerUserId in the Profiles section
  • observerModeObserver mode. Optional. Default is false. Controls Observer mode. Turn it on if you handle purchases and subscription status yourself and use Adapty for sending subscription events and analytics
  • logLevelDebugging 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.


Did this page help you?