React Native - Use fallback paywalls
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.
Before you follow the steps in this guide, download the fallback configuration files from Adapty.
Configuration
Android
-
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/rawfolder 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).
-
-
Update the
androidproperty of theFileLocationconstant:- If the file is located in the
assetsdirectory, pass the file's path relative to the directory. - If the file is located in the
res/rawdirectory, pass the name of the file without the extension.
- If the file is located in the
iOS
- Add the fallback JSON file to your project bundle: open the File menu in XCode and select the Add Files to "YourProjectName" option.
- Pass the name of your configuration file to the
iosproperty of theFileLocationconstant.
Example
- Current (v3.8+)
- Legacy (before v3.8)
//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);
//Legacy (before v3.8)
const paywallsLocation = {
ios: {
fileName: 'ios_fallback.json'
},
android: {
//if the file is located in 'android/app/src/main/assets/'
relativeAssetPath: 'android_fallback.json'
}
}
await adapty.setFallbackPaywalls(paywallsLocation);
Parameters:
| Parameter | Description |
|---|---|
| fileLocation | Object that represents the location of the fallback configuration file. |