Skip to content

Instantly share code, notes, and snippets.

@rkotzy
Created December 30, 2020 01:06
Show Gist options
  • Save rkotzy/7206285a01d6c2eb4ab821096983cddf to your computer and use it in GitHub Desktop.
Save rkotzy/7206285a01d6c2eb4ab821096983cddf to your computer and use it in GitHub Desktop.
import Purchases
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Purchases.configure(withAPIKey: "<your_api_key>")
Purchases.shared.delegate = self // set up the delegate
return true
}
}
extension AppDelegate : PurchasesDelegate {
func purchases(_ purchases: Purchases, didReceiveUpdated purchaserInfo: Purchases.PurchaserInfo) {
// Broadcast a notification when the PurchaserInfo changes
NotificationCenter.default.post(name: NSNotification.Name("kPurchaserInfoUpdated"), object: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment