Paywall preloading


Please checkout the new documentation in the SDK Configuration section.

To speed up the display of the view controller you can to preload it and use it later in your application.

Depending on your application, you may want to preload it when the application starts or when the main view controller starts.

The following example code shows two functions that help with preloading:

  1. preloadPaywall that should be called as soon as your possible in the life of your view controller or application
  2. nowDisplayThePaywall that should be called when you want to actually display the paywall to your user

This code is an example and should be adapted to your use case.

After the purchase is completed or cancelled the setCloseHandler is called with information about the transaction.

You may also find useful to read the Verify Subscription Status documentation.

import Glassfy
import UIKit

class ViewController: UIViewController {
    var paywallToDisplay: Glassfy.PaywallViewController? = nil;

    func preloadPaywall() {
        Glassfy.paywall(id: "mypaywall") { newPaywall, _ in
            self.paywallToDisplay = newPaywall
    func nowDisplayThePaywall() {
        if let paywallToDisplay = paywallToDisplay {
            paywallToDisplay.setCloseHandler { transaction, error in
                // handle the transaction
                // this is the transaction
                // it contains a permissions that
                // you can reference the code here for verifying the permissions:
            self.present(paywallToDisplay, animated: true, completion: nil)