Skip to main content

Use fallback paywalls in Kotlin Multiplatform SDK

To use fallback paywalls in your Kotlin Multiplatform project, you need to place the fallback JSON file in the appropriate location for each platform and then call the setFallbackPaywalls method.

Platform-specific setup

For Android

  1. Place the fallback file you downloaded in the Adapty Dashboard in the android/app/src/main/assets/ directory.
  2. Use the relative path from the assets directory as the assetId parameter.

For iOS

  1. In Xcode, use the menu File -> Add Files to "YourProjectName" to add the fallback file you downloaded in the Adapty Dashboard.
  2. Use the filename (including extension) as the assetId parameter.

Implementation

Here's an example of setting up fallback paywalls for both platforms:

import com.adapty.kmp.Adapty

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

The same assetId parameter works for both platforms, but the file needs to be placed in the correct location for each platform:

  • Android: android/app/src/main/assets/fallback.json
  • iOS: Add to Xcode project bundle as fallback.json

Parameters:

ParameterDescription
assetIdThe filename (including extension) of the fallback paywalls JSON file. For Android, this should be the relative path from the assets directory. For iOS, this should be the filename as it appears in the Xcode project bundle.
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.