In app purchase - Know when the subsription or pusrchase is expired

PHOTO EMBED

Fri Apr 12 2024 14:08:58 GMT+0000 (Coordinated Universal Time)

Saved by @Saurabh_Lodhi #swift #inapppurchase

Purchases.shared.delegate = self

extension YourClass: PurchasesDelegate {
    func purchases(_ purchases: Purchases, receivedUpdated customerInfo: Purchases.CustomerInfo) {
        if let entitlement = customerInfo.entitlements["your_entitlement_id"] {
            if entitlement.isActive == false {
                // subscription has expired
                print("Subscription has expired")
            } else {
                // subscription is active
                print("Subscription is active")
            }
        }
    }
}
content_copyCOPY