Skip to main content

By using the following code, I can receive PurchasesDelegate callback, when user subscribes to a free trial plan.

However, I am not able to receive PurchasesDelegate callback, when user cancels the free trial plan.

class AppDelegate: UIResponder, UIApplicationDelegate {

// https://www.revenuecat.com/docs/integrations/attribution/apple-search-ads
// https://www.revenuecat.com/docs/integrations/attribution/facebook-ads#3-send-revenuecat-events-into-facebook-ads-manager
private func initRevenueCat() {
Purchases.configure(with:
.init(withAPIKey: "appl_???")
.with(
purchasesAreCompletedBy: .myApp,
storeKitVersion: .storeKit2
)
)

Purchases.shared.attribution.enableAdServicesAttributionTokenCollection()

// Automatically collect the $idfa, $idfv, and $ip values
Purchases.shared.attribution.collectDeviceIdentifiers()
// REQUIRED: Set the Facebook anonymous Id
Purchases.shared.attribution.setFBAnonymousID(FBSDKCoreKit.AppEvents.shared.anonymousID)

Purchases.shared.delegate = self
}
}

extension AppDelegate: PurchasesDelegate {
func purchases(_ purchases: Purchases, receivedUpdated customerInfo: CustomerInfo) {
// handle any changes to customerInfo
}
}

May I know how I can fix this? Thanks.

Hi, the delegate on the device is only called if new PurchaserInfo is returned that is different than what was fetched previously. e.g. the subscription expiration date changes, active product changes, etc. This could occur by calling purchaserInfo directly, making a purchase, restoring a purchase, etc.
Subscription status changes aren't pushed to the delegate from the RevenueCat server so the auto-renewal turning off for the trial will not trigger the PurchasesDelegate callback.

I recommend listening to RevenueCat webhooks for a cancellation event to be alerted of when a trial’s auto-renewal turns off: https://www.revenuecat.com/docs/integrations/webhooks


Hi, currently, we only have a customer facing iOS app, without a server. Hence, we are not able to use webhook.

Can we workaround with this, actively calling

Purchases.shared.syncPurchases

followed by

Purchases.shared.getCustomerInfo

every 24 hours?

Thanks.


Reply