Skip to main content

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.

important

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

Configuration

  1. 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)
  2. Call the .setFallback method before you fetch the target paywall or onboarding.

  3. Set the assetId parameter, depending on your target platform.

    • Android: Use the file path relative to the assets directory.
    • iOS: Use the complete filename.
import com.adapty.kmp.Adapty

Adapty.setFallbackPaywalls(assetId = "fallback.json")
.onSuccess {
// Fallback paywalls loaded successfully
}
.onError { error ->
// Handle the error
}

Parameters:

ParameterDescription
assetIdFallback configuration filename (iOS).
Fallback configuration file path, relative to the assets directory (Android).
tip

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.