Unity - Use fallback paywalls

Les paywalls de secours sont pris en charge par le SDK Unity v2.11 et versions ultérieures.

To maintain a fluid user experience, it is important to set up fallbacks for your flows, 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 flow or paywall, and access the local onboarding configuration.

  • If the application cannot access the internet:

    It will be able to display a fallback flow or paywall. Onboardings include remote content and require an internet connection to function.

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

Configuration

  1. Ajoutez les fichiers de configuration de secours dans le répertoire commun Assets/StreamingAssets de votre projet.
  2. Appelez la méthode .SetFallback avant de récupérer le flow, le paywall ou l’onboarding cible.
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
});

SetFallback doit être exécuté avant que le SDK récupère le flow, le paywall ou l’onboarding cible.

Paramètres :

ParamètreDescription
fileNameLa chaîne contenant le nom du fichier de configuration de secours.