Skip to main content

Unity - Use fallback paywalls

warning

Fallback paywalls are supported by Unity SDK v2.11 and later.

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 files to the common Assets/StreamingAssets directory in your project.
  2. Call the .setFallback method before you fetch the target paywall or onboarding.
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 string with the name of the fallback configuration file.