Overriding Behaviours

URL opening behaviour

By default, AdaptyUI will open URLs in the default browser. If you want to change this behavior, please implement the following method:

public func paywallController(_ controller: AdaptyPaywallController, openURL url: URL) {
    UIApplication.shared.open(url, options: [:]) // the default behaviour
}

Presenting messages to user

We often have a situation where we need to show a message to a user. It can be, for example, an error that occurred during the purchase process, or, on the contrary, a message about successfully restored purchases. By default we show messages with texts in English using the UIAlertController, but if you need to customize this behavior, implement the following method:

public func paywallController(_ controller: AdaptyPaywallController,
                              buildDialogWith event: AdaptyUI.Event,
                              onDialogDismissed: (() -> Void)?) -> UIViewController {
    // the default behaviour:
    switch event {
    case .restored:
        return UIAlertController.buildRestoredAlert(onDialogDismissed: onDialogDismissed)
    case let .error(error):
        return UIAlertController.buildErrorAlert(error, onDialogDismissed: onDialogDismissed)
    }
}

🚧

If you have custom dialogs, be sure to call the onDialogDismissed function so that the AdaptyUI understands when you can continue.