Capacitor - Use fallback paywalls
Follow the instructions below to use the fallback paywalls in your mobile app code.
For Android
-
Place the fallback file you downloaded in the Adapty Dashboard to a directory on the native layer. There are 2 correct directories to put the file:
android/app/src/main/assets/
orandroid/app/src/main/res/raw/
.
Please keep in mind that theres/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).- For android/app/src/main/assets/: Pass the file path relatively to the
assets
directory, for example:{ relativeAssetPath: 'android_fallback.json' }
if you placed the file to the root ofassets
itself{ relativeAssetPath: '<additional_folder>/android_fallback.json' }
if you placed it in a child folder ofassets
- For android/app/src/main/res/raw/: Pass
{ rawResName: 'android_fallback' }
. Type the file name without the file extension.
- For android/app/src/main/assets/: Pass the file path relatively to the
-
Pass the result of step 2 to the
android
property ofFileLocation
.
For iOS
- In Xcode, use the menu File -> Add Files to "YourProjectName" to add the fallback file you downloaded in the Adapty Dashboard. Make sure the file is added to your app target.
- Pass
{ fileName: 'ios_fallback.json' }
to theios
property ofFileLocation
.
Here's an example of retrieving fallback paywall data from locally stored JSON files named android_fallback.json
and ios_fallback.json
.
import { adapty } from '@adapty/capacitor';
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:
Parameter | Description |
---|---|
fileLocation | The object represents the location of the file resource. |