Fetching paywalls & ViewConfiguration

If you have already configured a visual representation for your paywall in your Adapty Dashboard, you then need to load the paywall object and its view configuration.

Paywall can be obtained in the way you are already familiar with:

Adapty.getPaywall("YOUR_PAYWALL_ID") { result in
    switch result {
    case let .success(paywall):
        // use the paywall
    case let .failure(error):
        // handle the error
    }
}
Adapty.getPaywall("YOUR_PAYWALL_ID") { result ->
    when (result) {
        is AdaptyResult.Success -> {
            val paywall = result.value
            // the requested paywall
        }
        is AdaptyResult.Error -> {
            val error = result.error
            // handle the error
        }
    }
}
Adapty.getPaywall("YOUR_PAYWALL_ID", result -> {
    if (result instanceof AdaptyResult.Success) {
        AdaptyPaywall paywall = ((AdaptyResult.Success<AdaptyPaywall>) result).getValue();
        // the requested paywall
      
    } else if (result instanceof AdaptyResult.Error) {
        AdaptyError error = ((AdaptyResult.Error) result).getError();
        // handle the error
      
    }
});
import 'package:adapty_flutter/adapty_flutter.dart';

try {
  final paywall = await Adapty().getPaywall(id: paywallId);
} on AdaptyError catch (adaptyError) {
  // handle the error
} catch (e) {
  // handle the error
}
import {adapty} from 'react-native-adapty';

try {
  const paywall = await adapty.getPaywall("YOUR_PAYWALL_ID");
} catch (error) {
  // handle the error 
}

Adapty.GetPaywall(id, (paywall, error) => {
  // handle the error and use the paywall
});

After fetching the paywall call the getViewConfiguration(forPaywall:locale:) method to load the view configuration (for crossplatform SDKs you should call createPaywallView since there is no need to fetch view configuration manually):

import Adapty

AdaptyUI.getViewConfiguration(forPaywall: paywall, locale: "en") { result in
    switch result {
    case let .success(viewConfiguration):
        // use loaded configuration
    case let .failure(error):
        // handle the error
    }
}
Adapty.getViewConfiguration(paywall, locale = "en") { result ->
    when(result) {
        is AdaptyResult.Success -> {
            val viewConfiguration = result.value
            // use loaded configuration
        }
        is AdaptyResult.Error -> {
            val error = result.error
            // handle the error
        }
    }
}
Adapty.getViewConfiguration(paywall, "en", result -> {
    if (result instanceof AdaptyResult.Success) {
        AdaptyViewConfiguration viewConfiguration =
                ((AdaptyResult.Success<AdaptyViewConfiguration>) result).getValue();
        // use loaded configuration
    } else if (result instanceof AdaptyResult.Error) {
        AdaptyError error = ((AdaptyResult.Error) result).getError();
        // handle the error
    }
});
import 'package:adapty_ui_flutter/adapty_ui_flutter.dart';

try {
  final view = await AdaptyUI().createPaywallView(paywall: paywall);
} on AdaptyError catch (e) {
  // handle the error
} catch (e) {
  // handle the error
}
import {createPaywallView} from '@adapty/react-native-ui';

try {
  const view = await createPaywallView(paywall);
} catch (error) {
  // handle the error
}

AdaptyUI.CreatePaywallView(paywall, locale: 'en', preloadProducts: true, (view, error) => {
  // use the view
});

📘

If you are using multiple languages, learn about Paywall builder localization and how to use locale codes correctly here

Once you have successfully loaded the paywall and view configuration (or in case of crossplatform SDKs - view), you can proceed to displaying the visual paywall.