Handling App Store Promo Codes
You can display a sheet that enables users to redeem subscription offer codes that you configure in App Store Connect by using the following code
SKPaymentQueue.default().presentCodeRedemptionSheet()
You can also redirect the user to the app store using this link :
https://apps.apple.com/redeem?ctx=offer_code&id={appstoreappid_app_id}
If you are checking the status of the subscriptions using the permissions everything is handled transparently by Glassfy, but if you want to be notified when a purchase is completed successfully you need to implement a delegate as in the following example.
@main
class AppDelegate: [...], Glassfy.PurchaseDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Glassfy.initialize(apiKey: "YOUR_API_KEY")
Glassfy.setPurchaseDelegate(self)
[...]
}
func didPurchaseProduct(transaction: Glassfy.Transaction) {
// handle transation
// see transaction documentation here https://docs.glassfy.io/docs/transaction
}
}
Updated 12 months ago