Skip to main content

Use fallbacks in Unity SDK

To use fallback paywalls and onboardings, call the SetFallback method.

For this to work, place the fallback JSON file you downloaded in the Adapty Dashboard in the Assets/StreamingAssets folder of your Unity project.

Place the SetFallback method in your code before fetching a paywall or onboarding, ensuring that the mobile app possesses it when a fallback paywall or onboarding is required to replace the standard one.

Here's an example of retrieving fallback paywall or onboarding data from locally stored JSON files named android_fallback.json and ios_fallback.json.

using UnityEngine;
using AdaptySDK;

#if UNITY_IOS
string fileName = "ios_fallback.json";
#elif UNITY_ANDROID
string fileName = "android_fallback.json";
#else
// Optional: handle Editor or other platforms
string fileName = "fallback.json";
#endif

Adapty.SetFallback(fileName, (error) => {
if (error != null) {
Debug.LogError($"Failed to set fallback: {error}");
return;
}

// Fallback set successfully
});

Parameters:

ParameterDescription
fileNameThe object represents the name of the file resource.