-
Notifications
You must be signed in to change notification settings - Fork 54
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
PaywallActivityLauncher: Add callback indicating whether the paywall was displayed when presented conditionally to an entitlement identifier #1542
Conversation
…ting with a given entitlement identifier
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1542 +/- ##
=======================================
Coverage 84.14% 84.14%
=======================================
Files 218 218
Lines 7196 7196
Branches 1007 1007
=======================================
Hits 6055 6055
Misses 750 750
Partials 391 391 ☔ View full report in Codecov by Sentry. |
*/ | ||
@ExperimentalPreviewRevenueCatUIPurchasesAPI | ||
interface PaywallDisplayCallback { | ||
fun onPaywallShouldDisplay(shouldDisplayPaywall: Boolean) |
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 sounds very confusing. The parameter is named as a question instead of a noun, as if it was a function. How about:
fun onPaywallShouldDisplay(shouldDisplayPaywall: Boolean) | |
fun onPaywallDisplay(wasDisplayed: Boolean) |
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.
Yeah, I was unsure naming this... onPaywallDisplay
is not fully correct, since it's possible the paywall was not displayed so I had some back and forth in my mind on this... What do you think of fun onPaywallDisplayResult(wasDisplayed: Boolean)
?
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 did this rename in 2fad819. Lmk what you think!
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, apart from @NachoSoto comment about naming
fun checkPaywallDisplayCallback() { | ||
@Suppress("EmptyFunctionBlock") | ||
val paywallDisplayCallback = object : PaywallDisplayCallback { | ||
override fun onPaywallShouldDisplay(shouldDisplayPaywall: Boolean) {} |
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.
Not needed but wanted to suggest it just in case you think it's a good idea. What do you think about returning a DisplayPaywallResult
in case we want to add more stuff to the result in the future?
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 it's a good point... Do you have any idea of anything else we might want to return? I think right now a simple boolean suffices so I would prefer not to complicate the API without need.
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.
Sounds good!
**This is an automatic release.** ### RevenueCatUI * PaywallActivityLauncher: Add callback indicating whether the paywall was displayed when presented conditionally to an entitlement identifier (#1542) via Toni Rico (@tonidero) * Report restore errors when using PaywallActivityLauncher (#1544) via Toni Rico (@tonidero) * Remove scroll in Template 2 and 5 in Footer mode (#1545) via Cesar de la Vega (@vegaro) ### Bugfixes * Opens PaywallFooterView (#1541) via Cesar de la Vega (@vegaro) ### Dependency Updates * Bump fastlane from 2.217.0 to 2.218.0 (#1543) via dependabot[bot] (@dependabot[bot]) Co-authored-by: revenuecat-ops <[email protected]>
Description
In the hybrid SDKs, we want to return a result from the
presentPaywall
/presentPaywallIfNeeded
methods with the result of the paywall. However, we can't do that easily sincepresentPaywallIfNeeded
might not present the paywall at all, and there was no way to know whether the paywall was displayed in that case until now.This adds a new parameter to the
launchIfNeeded
methods that receive arequiredEntitlementIdentifier
that will indicate whether the paywall was displayed. Note that this isn't added to thelaunchIfNeeded
method that received a block of code, since the client should know in that case whether the paywall was displayed or not, depending on the result of that callback.