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
- Place the fallback file you downloaded in the Adapty Dashboard in the
android/app/src/main/assets/
directory. - Use the relative path from the
assets
directory as theassetId
parameter.
For iOS
- In Xcode, use the menu File -> Add Files to "YourProjectName" to add the fallback file you downloaded in the Adapty Dashboard.
- 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:
Parameter | Description |
---|---|
assetId | The 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.