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

Add UI Preview Mode to SDK #4693

Closed
wants to merge 6 commits into from
Closed

Conversation

ajpallares
Copy link
Member

@ajpallares ajpallares commented Jan 21, 2025

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-android and hybrids

Motivation

We need to add a specific mode for the SDK to allow Paywall Previews in the RevenueCat app

Description

The UI Preview Mode of the SDK should limit all the functionality of the SDK to only enable implementing the Paywall Previews functionality in the RevenueCat, so that developers can properly test their paywalls on their own devices.

This is currently a WIP, as it still only contains the changes implemented by @aboedo.

@RevenueCat-Danger-Bot
Copy link

1 Error
🚫 Label the PR using one of the change type labels. If you are not sure which label to use, choose pr:other.
Label Description
pr:feat A new feature. Use along with pr:breaking to force a major release.
pr:fix A bug fix. Use along with pr:force_minor to force a minor release.
pr:other Other changes. Catch-all for anything that doesn't fit the above categories. Releases that only contain this label will not be released. Use along with pr:force_patch, or pr:force_minor to force a patch or minor release.
pr:RevenueCatUI Use along any other tag to mark a PR that only contains RevenueCatUI changes
pr:next_release Preparing a new release
pr:dependencies Updating a dependency
pr:phc_dependencies Updating purchases-hybrid-common dependency

Generated by 🚫 Danger

Copy link
Member

@JayShortway JayShortway left a comment

Choose a reason for hiding this comment

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

Very clean and readable! 😗👌 Just 2 suggestions.

let productType = productTypes[index % productTypes.count]

let introductoryDiscount: TestStoreProductDiscount? = {
guard productType.period != nil && Bool.random() else { return nil }
Copy link
Member

Choose a reason for hiding this comment

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

I like the idea, but the randomness could add friction if you want to see a discount and all random()s happen to be false. (You'll need to go back and reopen the preview / the app.)

What do you think about having a fixed (set of) product type(s) always having a discount, e.g. monthly and yearly?

Copy link
Member Author

Choose a reason for hiding this comment

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

I totally see your point about the friction due to the randomness. I also believe that what we show in previews should be more deterministic.
On the other hand, I do imagine some clients wanting to show the exact information of their products on the previews. However, the introduced randomness does not solve this problem either.
WDYT @aboedo?

Copy link
Member

Choose a reason for hiding this comment

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

I do imagine some clients wanting to show the exact information of their products on the previews.

Just for some context: this is something I believe we will do at some point. We could on top of that allow users to configure the preview before/when showing it, e.g. with a setting that controls discounts. However these are not solutions for in this PR haha.

This is not a blocker for me btw!

Copy link
Member

@aboedo aboedo Jan 22, 2025

Choose a reason for hiding this comment

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

Makes sense, I can imagine the frustration and the confusion if the paywall looks different between opens.

Agreed with Joop that eventually we'll want to get realistic data in there, but in the meantime probably the easiest way to go would be to have a way to tell the SDK what to show.

That way we could do something like what the dashboard does, where it allows you to select whether to preview with intro offer eligible or not.

Probably not something that needs to go into the MVP of this feature and can be added on later before shipping to prod.

And it will set us up nicely for doing something similar for Customer Center, where we'll inevitably need to find a way to select whether to show the CC as a user with an active subscription would see it vs empty subs

Sources/Misc/DangerousSettings.swift Outdated Show resolved Hide resolved
Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

Looking good! Just another comment of possible improvements to make the previews more realistic/more deterministic

]

let products = productIdentifiers.enumerated().map { index, identifier -> StoreProduct in
let productType = productTypes[index % productTypes.count]
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could act a bit smarter here and instead of assigning basically a random period to each product, we could try to get the package type provided by the offerings (which has the duration). In case the package type is custom, we could then do something "smart" like analyzing the product id for some keywords like week, month, year.... To assign the duration. And then if we don't find any, as a fallback, assign a random period.

@ajpallares
Copy link
Member Author

I'll open separate PRs for the new API for enabling the UI Preview mode and for the specific implementation details of this new mode

@ajpallares ajpallares closed this Jan 27, 2025
@ajpallares
Copy link
Member Author

See #4714 for the new API for the UI Preview mode

@ajpallares ajpallares mentioned this pull request Jan 30, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants