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

UI Preview Mode: mock products #4735

Merged
merged 7 commits into from
Jan 30, 2025
Merged

UI Preview Mode: mock products #4735

merged 7 commits into from
Jan 30, 2025

Conversation

ajpallares
Copy link
Member

@ajpallares ajpallares commented Jan 29, 2025

Checklist

  • If applicable, unit tests

Motivation

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 app.

Description

Mock the StoreProducts, as we cannot fetch them from StoreKit

Comment on lines 303 to 313
// For mocking purposes: all yearly subscriptions have a 1-week free trial
guard productType.period?.unit == .year else { return nil }
return TestStoreProductDiscount(
identifier: "intro",
price: 0,
localizedPriceString: "$0.00",
paymentMode: .freeTrial,
subscriptionPeriod: SubscriptionPeriod(value: 1, unit: .week),
numberOfPeriods: 1,
type: .introductory
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Based on @JayShortway's comment here, I'm only adding mocked introductory offers for yearly subscriptions

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 so far!

Sources/Purchasing/OfferingsManager.swift Outdated Show resolved Hide resolved
} else {
packageType = .custom
}
return ProductTypeMock(packageType: packageType) ?? .default
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I'm wondering if we should default always to a lifetime in this case.... But then again, I don't have a better alternative, so I think this is ok for now!

@ajpallares ajpallares requested review from a team and aboedo January 30, 2025 14:03
@ajpallares ajpallares marked this pull request as ready for review January 30, 2025 14:03
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.

A couple of suggestions but LGTM!

Sources/Purchasing/OfferingsManager.swift Outdated Show resolved Hide resolved
Sources/Purchasing/OfferingsManager.swift Outdated Show resolved Hide resolved
@ajpallares ajpallares requested review from tonidero and a team January 30, 2025 15:42
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.

LGTM!

@ajpallares ajpallares merged commit 12068cc into main Jan 30, 2025
10 checks passed
@ajpallares ajpallares deleted the uiPreviewMode/mockProducts branch January 30, 2025 16:26
@@ -12,7 +12,7 @@
// Created by Juanpe Catalán on 9/8/21.

import Nimble
@testable import RevenueCat
@testable @_spi(Internal) import RevenueCat
Copy link
Contributor

Choose a reason for hiding this comment

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

neat 💅

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.

3 participants