I have the following code, but only the paywallViewControllerWasDismissed
method is being called. Other PaywallViewControllerDelegate
methods are not triggered. Any solution for this?
import Foundation
import RevenueCatUI
import RevenueCat
import UIKit
class RevenueCatManager: NSObject {
static let shared = RevenueCatManager()
private override init() {}
func presentPaywall(from viewController: UIViewController, offeringID: String) {
Purchases.shared.getOfferings { (offerings, error) in
guard let offering = offerings?.offering(identifier: offeringID) else {
print("⚠️ Error fetching offering with ID: \(offeringID) - \(error?.localizedDescription ?? "Unknown error")")
return
}
DispatchQueue.main.async {
let paywallVC = PaywallViewController(offering: offering)
paywallVC.delegate = self
paywallVC.modalPresentationStyle = .fullScreen
viewController.present(paywallVC, animated: true)
}
}
}
}
extension RevenueCatManager: PaywallViewControllerDelegate {
func paywallViewController(_ controller: PaywallViewController, didFinishPurchasingWith customerInfo: CustomerInfo) {
print("✅ Purchase successful: \(customerInfo)")
}
func paywallViewControllerWasDismissed(_ controller: PaywallViewController) {
print("❌ Paywall was dismissed")
}
func paywallViewControllerDidStartPurchase(_ controller: PaywallViewController) {
print("⏳ Purchase process started")
}
func paywallViewControllerDidCancelPurchase(_ controller: PaywallViewController) {
print("⚠️ Purchase was canceled")
}
}