-
Notifications
You must be signed in to change notification settings - Fork 84
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 #1134
Conversation
} | ||
|
||
return RNPurchases.eligibleWinBackOffersForProductIdentifier( | ||
aPackage.product.identifier |
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.
Here, we call the eligibleWinBackOffersForProductIdentifier
for the package's product ID. We do this so that we only have to implement the offer caching logic in PHC once instead of twice for both functions
ios/RNPurchases.m
Outdated
}]; | ||
} else { | ||
NSString *description = @"iOS win-back offers are only available on iOS 18.0 or greater."; | ||
NSError *error = [[NSError alloc] initWithDomain:@"RCPurchasesErrorCodeDomain" |
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.
I think RCPurchasesErrorCodeDomain
should be a symbol reference, not a string.
RCPurchasesErrorCodeDomain
is auto-generated in the Objc bridging header in purchases-ios
as RevenueCat.ErrorCode
from:
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.
This might be a good candidate to extract as a helper that builds an "unsupported" error with a custom message
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.
Love this! Made these changes here: e2f467a
} | ||
} | ||
|
||
RCT_EXPORT_METHOD(purchaseProductWithWinBackOffer:(nonnull NSString *)productID |
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.
Objc conventions make me think this WithWinBackOffer
expect the next parameter to be the winback offer. I think it might be clearer without that part, and it more closely follows the method signature in PHC.
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.
I tried changing the name of this function to purchaseProduct
, but then I started seeing namespace collisions with the other purchaseProduct function:
RNPurchases.purchaseProduct was called with 6 arguments but expects 2 arguments. If you haven't changed this method yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.
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.
Update in case anyone reads this later: we decided not to make this change since Typescript doesn't have named parameters and since this is an internal API
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.
Left some minor comments but functionality looks solid 👍
**This is an automatic release.** ## RevenueCat SDK ### 📦 Dependency Updates * [AUTOMATIC BUMP] Updates purchases-hybrid-common to 13.12.0 (#1136) via RevenueCat Git Bot (@RCGitBot) * [Android 8.10.3](https://github.com/RevenueCat/purchases-android/releases/tag/8.10.3) * [iOS 5.12.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.12.0) * [iOS 5.11.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.11.0) * [iOS 5.10.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.10.0) * [iOS 5.9.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.9.0) * [AUTOMATIC BUMP] Updates purchases-hybrid-common to 13.11.0 (#1133) via RevenueCat Git Bot (@RCGitBot) * [Android 8.10.3](https://github.com/RevenueCat/purchases-android/releases/tag/8.10.3) * [iOS 5.12.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.12.0) * [iOS 5.11.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.11.0) * [iOS 5.10.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.10.0) * [iOS 5.9.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.9.0) * [AUTOMATIC BUMP] Updates purchases-hybrid-common to 13.10.0 (#1132) via RevenueCat Git Bot (@RCGitBot) * [Android 8.10.3](https://github.com/RevenueCat/purchases-android/releases/tag/8.10.3) * [iOS 5.12.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.12.0) * [iOS 5.11.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.11.0) * [iOS 5.10.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.10.0) * [iOS 5.9.0](https://github.com/RevenueCat/purchases-ios/releases/tag/5.9.0) ### Win-back Offers #### ✨ New Features * Support Fetching and Redeeming Win-Back Offers on Custom Paywall (#1134) via Will Taylor (@fire-at-will) --------- Co-authored-by: RevenueCat CI <[email protected]>
This PR exposes four new functions to allow developers to fetch & redeem win-back offers that a subscriber is eligible for in their custom paywalls. These functions only function on iOS 18.0+ and require StoreKit 2 to be used.
Fetching Eligible Win-Back Offers
Redeeming Win-Back Offers
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.