Present onboardings in Unity SDK

If you’ve customized an onboarding using the builder, you don’t need to worry about rendering it in your Unity app code to display it to the user. Such an onboarding contains both what should be shown within the onboarding and how it should be shown.

Before you start, ensure that:

  1. You have installed Adapty Unity SDK 3.14.0 or later.
  2. You have created an onboarding.
  3. You have added the onboarding to a placement.

To display an onboarding, use the view.Present() method on the view created by the CreateOnboardingView method. Each view can only be used once. If you need to display the paywall again, call CreateOnboardingView one more to create a new view instance.

Reusing the same view without recreating it may result in an AdaptyUIError.viewAlreadyPresented error.

view.Present((presentError) => {
    if (presentError != null) {
        // handle the error
    }
};

Configure iOS presentation style

Configure how the onboarding is presented on iOS by passing the iosPresentationStyle parameter to the Present() method. The parameter accepts AdaptyUIIOSPresentationStyle.FullScreen (default) or AdaptyUIIOSPresentationStyle.PageSheet values.

view.Present(AdaptyUIIOSPresentationStyle.PageSheet, (error) => {
    // handle the error
});

Customizing how links open in onboardings is supported starting from Adapty SDK v. 3.15.

By default, links in onboardings open in an in-app browser, providing a seamless experience by displaying web pages within your application without switching apps.

To open links in an external browser instead, pass AdaptyWebPresentation.ExternalBrowser to the CreateOnboardingView method:

AdaptyUI.CreateOnboardingView(
    onboarding,
    AdaptyWebPresentation.ExternalBrowser, // default — InAppBrowser
    (view, error) => {
        if (error != null) {
            // handle the error
            return;
        }

        // present the onboarding view
        view.Present((presentError) => {
            if (presentError != null) {
                // handle the error
            }
        });
    }
);

Available options:

  • AdaptyWebPresentation.InAppBrowser - Opens links in an in-app browser (default)
  • AdaptyWebPresentation.ExternalBrowser - Opens links in the device’s external browser