-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Fetching and Redeeming Win-Back Offers on Custom Paywall #366
Conversation
@@ -41,6 +41,29 @@ internal extension PurchasesPlugin { | |||
return handleResponse | |||
} | |||
|
|||
func getCompletionBlockHandlerForArrayResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function signature for fetching eligible winback offers in PHC is:
static func eligibleWinBackOffers(
for productIdentifier: String,
completion: @escaping ([[String: Any]]?, ErrorContainer?) -> Void
)
Note the [[String: Any]]?
in the callback - it returns an array of objects. This function allows us to parse that response type, since the normal getCompletionBlockHandler
assumes a return type of [String: Any]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nicely done!
@PluginMethod(returnType = PluginMethod.RETURN_PROMISE) | ||
fun purchasePackageWithWinBackOffer(call: PluginCall) { | ||
logNotSupportedFunctionalityInAndroid("purchasePackageWithWinBackOffer") | ||
call.unavailable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm right, we probably should use unavailable
for more methods 😅 (not for this PR!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing the change!
Description
This PR introduces four new functions to the Capacitor SDK that enables developers to fetch & redeem win-back offers on their custom paywalls. These functions are only supported on on iOS 18.0+ and require StoreKit 2 to be used.
Fetching eligible win-back offers
Redeeming win-back offers
Each function throws an appropriate error if it is called on an unsupported platform, OS version, or StoreKit version.
Other Changes
The PurchaseTester app was updated with a new screen to support testing these flows
Testing
All flows were tested manually through the new screen in the PurchaseTester app.