Skip to content
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

Merged
merged 6 commits into from
Jan 3, 2024

Conversation

tonidero
Copy link
Contributor

@tonidero tonidero commented Jan 2, 2024

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 since presentPaywallIfNeeded 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 a requiredEntitlementIdentifier that will indicate whether the paywall was displayed. Note that this isn't added to the launchIfNeeded 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.

Copy link

codecov bot commented Jan 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a0404de) 84.14% compared to head (2fad819) 84.14%.

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.
📢 Have feedback on the report? Share it here.

@tonidero tonidero marked this pull request as ready for review January 2, 2024 14:18
@tonidero tonidero requested a review from a team January 2, 2024 14:19
*/
@ExperimentalPreviewRevenueCatUIPurchasesAPI
interface PaywallDisplayCallback {
fun onPaywallShouldDisplay(shouldDisplayPaywall: Boolean)
Copy link
Contributor

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:

Suggested change
fun onPaywallShouldDisplay(shouldDisplayPaywall: Boolean)
fun onPaywallDisplay(wasDisplayed: Boolean)

Copy link
Contributor Author

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)?

Copy link
Contributor Author

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!

Copy link
Contributor

@vegaro vegaro left a 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) {}
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

@tonidero tonidero requested review from vegaro and NachoSoto January 2, 2024 14:38
@tonidero tonidero enabled auto-merge (squash) January 2, 2024 14:42
@NachoSoto NachoSoto disabled auto-merge January 2, 2024 14:47
@tonidero tonidero merged commit 33f5eb7 into main Jan 3, 2024
@tonidero tonidero deleted the add-paywall-displayed-callback-activity-launcher branch January 3, 2024 12:09
vegaro pushed a commit that referenced this pull request Jan 3, 2024
**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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants