Skip to main content

React Native - Use fallback paywalls

warning

Fallback paywalls are supported by React Native SDK v2.11 and later.

To maintain a fluid user experience, it is important to set up fallbacks for your paywalls and onboardings. This precaution extends the application's capabilities in case of partial or complete loss of internet connection.

  • If the application cannot access Adapty servers:

    It will be able to display a fallback paywall, and access the local onboarding configuration.

  • If the application cannot access the internet:

    It will be able to display a fallback paywall. Onboardings include remote content and require an internet connection to function.

important

Before you follow the steps in this guide, download the fallback configuration files from Adapty.

Configuration

Android

  1. Add the fallback configuration file to your application. Select one of the following directories:

    • android/app/src/main/assets/

    • android/app/src/main/res/raw/

      Note: The res/raw folder has a special file naming convention (start with a letter, no capital letters, no special characters except for the underscore, and no spaces in the names).

  2. Update the android property of the FileLocation constant:

    • If the file is located in the assets directory, pass the file's path relative to the directory.
    • If the file is located in the res/raw directory, pass the name of the file without the extension.

iOS

  1. Add the fallback JSON file to your project bundle: open the File menu in XCode and select the Add Files to "YourProjectName" option.
  2. Pass the name of your configuration file to the ios property of the FileLocation constant.

Example

//after v3.8
const fileLocation = {
ios: {
fileName: 'ios_fallback.json'
},
android: {
//if the file is located in 'android/app/src/main/assets/'
relativeAssetPath: 'android_fallback.json'
}
}
await adapty.setFallback(fileLocation);

Parameters:

ParameterDescription
fileLocationObject that represents the location of the fallback configuration file.