Paywall preloading
Deprecated
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:
preloadPaywall
that should be called as soon as your possible in the life of your view controller or applicationnowDisplayThePaywall
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 https://docs.glassfy.io/docs/transaction
// it contains a permissions that https://docs.glassfy.io/docs/permissions
// you can reference the code here for verifying the permissions:
// https://docs.glassfy.io/docs/verify-subscription-status
}
self.present(paywallToDisplay, animated: true, completion: nil)
}
}
}
Updated over 1 year ago