-
Notifications
You must be signed in to change notification settings - Fork 382
Add Test Store purchase UI #5403
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
Conversation
# Conflicts: # Sources/Misc/SystemInfo.swift # Sources/Purchasing/Configuration.swift # Sources/Purchasing/Purchases/Purchases.swift # Tests/UnitTests/Purchasing/ConfigurationTests.swift
…ase alert strings
📸 Snapshot Test705 unchanged
🛸 Powered by Emerge Tools |
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.
Very nice!
var message = "⚠️ This is a test purchase and should be tested with real products using " + | ||
"an Apple API key from RevenueCat.\n\n" |
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 is slightly confusing imo. How about something like:
This is a test purchase and should only be used during development. In production, use an Apple API key from RevenueCat.
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 like it! It may be worth changing this copy also in react-native-purchases @tonidero?
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.
Yup! Will update my branch!
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 looks great to me! Nice job!!
|
||
private extension PurchasesOrchestrator { | ||
|
||
func handlePurchase(testStoreProduct: TestStoreProduct, completion: @escaping PurchaseCompletedBlock) { |
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 see we created a TestStorePurchaseHandler
. Would it make sense to also move all this logic there? Mostly want to avoid increasing the size of the orchestrator too much... and this all seems like it could live there?
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.
Yes, I think that's a good point. I intend to add the whole after-purchase logic in a separate PR so I'll take this into account to add all the logic in the TestStorePurchaseHandler
. I agree it's better to keep PurchasesOrchestrator
as dedicated as possible to the "real" purchases logic.
Thanks for the suggestion!
if userConfirmed { | ||
// WIP: Implement actual test purchase completion logic | ||
// For now, we'll simulate a successful purchase | ||
completion(nil, nil, nil, false) |
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.
Do we need to return the CustomerInfo for this? Though I'm ok adding that later once we add the actual implementation I 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.
Yes, exactly. We need to return the CustomerInfo
here. Right now, confirming the purchase crashes due to it not containing the CustomerInfo
. I could return the same mocked CustomerInfo
that I used for UI preview mode. It will only contain minimum hardcoded information, but I think it's better than a crash. WDYT?
It's not a big deal as this is all under the TEST_STORE
flag, but perhaps it's better a hardcoded response than a crash anyway.
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... either that or just fetching the latest customer info... but that's probably harder, and not something we will need to do anyway, so I think a hardcoded version is ok for now!
1f9948b
to
cc50f53
Compare
@RCGitBot please test |
Since the minimum supported versions of the SDK are iOS 13 and tvOS 13
if #available(iOS 15.0, macCatalyst 15.0, *) { | ||
window = nil | ||
} else { | ||
// Fallback to legacy approach on OSs where UIApplication's `windows` property is not deprecated | ||
window = application.windows.first(where: { $0.isKeyWindow }) | ||
} |
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.
UIApplication
's windows
property is deprecated since iOS 15, visionOS 1, so this was triggering a warning that was making CI fail. I've tested with visionOS 1, iOS 15 and tvOS and it works properly (the window
is taken from application.currentWindowScene
above
I did some cleanup and added small changes based on the review comments and also to remove some deprecation warnings. |
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.
Looks great!
This PR integrates the (fake) purchase UI for Test Store products (under the
TEST_STORE
compiler flag).Screenshots
iOS
macOS
tvOS
visionOS
watchOS