Kotlin Multiplatform - Use fallback paywalls
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
-
Add the fallback configuration file to your application.
- If your target platform is Android, move the fallback configuration file to the
android/app/src/main/assets/folder. - If your target platform is iOS, add the fallback JSON file to your project bundle. (File -> Add Files to YourProjectName)
- If your target platform is Android, move the fallback configuration file to the
-
Call the
.setFallbackmethod before you fetch the target paywall or onboarding. -
Set the
assetIdparameter, depending on your target platform.- Android: Use the file path relative to the
assetsdirectory. - iOS: Use the complete filename.
- Android: Use the file path relative to the
import com.adapty.kmp.Adapty
Adapty.setFallbackPaywalls(assetId = "fallback.json")
.onSuccess {
// Fallback paywalls loaded successfully
}
.onError { error ->
// Handle the error
}
Parameters:
| Parameter | Description |
|---|---|
| assetId | Fallback configuration filename (iOS). Fallback configuration file path, relative to the assets directory (Android). |
Want to see a real-world example of how Adapty SDK is integrated into a mobile app? Check out our sample apps, which demonstrate the full setup, including displaying paywalls, making purchases, and other basic functionality.