RevenueCat / purchases-ios

In-app purchases and subscriptions made easy. Support for iOS, watchOS, tvOS, macOS, and visionOS.
https://www.revenuecat.com/
MIT License
2.22k stars 295 forks source link

Provide the package in the paywallFooter closures like PurchaseOrRestoreCompletedHandler, PurchaseCancelledHandler or PurchaseFailureHandler #4017

Open alpennec opened 1 week ago

alpennec commented 1 week ago

Hello,

I'm using the paywallFooter ViewModifier in my SwiftUI app. I want to track some analytics regarding the package being purchased.

As of today, we don't have access to this package in all closures, it's only available in the PurchaseOfPackageStartedHandler. Can you please add the package in the PurchaseOrRestoreCompletedHandler, PurchaseCancelledHandler and PurchaseFailureHandler?

Thanks, Axel

mshmoustafa commented 1 week ago

Hey @alpennec, I'll ask the engineering team if we can add the package to PurchaseFailureHandler and PurchaseCancelledHandler, but I'm curious how you would want the package to be added to PurchaseOrRestoreCompletedHandler. The restore operation is not package specific. Purchases of none, one, or some products might be restored as a result of restorePurchases and it's also not always possible to map purchases of products to packages since you typically don't need to display an offering in order to restore purchases. Was there something you had in mind for PurchaseOrRestoreCompletedHandler?

alpennec commented 6 days ago

Hey @mshmoustafa,

Thanks for answering.

You're right, the PurchaseOrRestoreCompletedHandler when restoring is not package specific. But is it necessary that this handler is used for both purchase success and restore success? I would imagine a PurchaseCompletedHandler and a PurchasesRestoredHandler that could be used for specific logic. Like I want to show a specific success alert to my users when they purchase and another one when they restore. This is not necessarily the same logic in apps.

Thanks. Axel