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

Paywalls: new .onPurchaseStarted(package) modifier #3693

Merged
merged 4 commits into from
Feb 21, 2024
Merged

Conversation

vegaro
Copy link
Contributor

@vegaro vegaro commented Feb 15, 2024

Similar to #3627.

This API is available in:

  • PaywallView()
  • .presentPaywallIfNeeded
  • .paywallFooter
  • PaywallViewControllerDelegate

@vegaro vegaro added the pr:feat A new feature label Feb 15, 2024
@vegaro vegaro changed the title Add package to purchaseStarted Paywalls: new .onPurchaseStarted(package) modifier Feb 15, 2024
vegaro added a commit that referenced this pull request Feb 20, 2024
While working on #3693 I noticed we were missing some API tests that
would be helpful for that PR
@vegaro vegaro force-pushed the purchase-started branch 2 times, most recently from 3cd5f28 to d3b028d Compare February 20, 2024 14:06
vegaro added a commit that referenced this pull request Feb 20, 2024
Since we are deprecating the old function in
https://github.com/RevenueCat/purchases-ios/pull/3693/files

I thought it will be simpler to just add both `restoreStarted` and the
new `purchaseStarted(package:)` in the same release. We haven't made a
release since I merged #3694 so these are safe to remove for now.

I open this PR in case we want to make a release before #3693 is
finished.
@vegaro vegaro force-pushed the purchase-started branch 3 times, most recently from 41d9b2d to d13cc83 Compare February 20, 2024 19:56
public func presentPaywallIfNeeded(
requiredEntitlementIdentifier: String,
offering: Offering? = nil,
fonts: PaywallFontProvider = DefaultPaywallFontProvider(),
presentationMode: PaywallPresentationMode = .default,
purchaseStarted: PurchaseStartedHandler? = nil,
purchaseStarted: @escaping PurchaseStartedHandler,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this non nullable so the function wouldn't collide if someone was only passing requiredEntitlementIdentifier. I also had to made it @escaping. Is that considered a breaking change?

Copy link
Member

Choose a reason for hiding this comment

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

@vegaro I'm not certain if the @escaping is breaking changing (I'd have to experiment) but making this non-nullable is a breaking change, isn't it? 😬

If somebody was using this function without purchaseStarted, it will now require them to have purchaseStarted?

Copy link
Member

Choose a reason for hiding this comment

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

Did the API tester for this break? That would really let us know, wouldn't it? 🤷‍♂️

Copy link
Contributor Author

@vegaro vegaro Feb 21, 2024

Choose a reason for hiding this comment

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

It didn't fail, that's why I am not sure 🤷‍♂️

If somebody was using this function without purchaseStarted, it will now require them to have purchaseStarted?

If they were not passing it, it will use the new non-deprecated function automatically (that one has it as nullable)

Copy link
Member

Choose a reason for hiding this comment

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

Ahhh, okay! That makes sense then 😊 I think this should be good then!

public func presentPaywallIfNeeded(
offering: Offering? = nil,
fonts: PaywallFontProvider = DefaultPaywallFontProvider(),
presentationMode: PaywallPresentationMode = .default,
shouldDisplay: @escaping @Sendable (CustomerInfo) -> Bool,
purchaseStarted: PurchaseStartedHandler? = nil,
purchaseStarted: @escaping PurchaseStartedHandler,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here. If someone was not passing anything or passing let's say just offering, it would collide with the new version

@vegaro vegaro marked this pull request as ready for review February 21, 2024 12:46
@vegaro vegaro requested a review from a team February 21, 2024 12:46
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! I don't think the escaping change is breaking but might be good to confirm with @joshdholtz and/or @MarkVillacampa

RevenueCatUI/View+PresentPaywallFooter.swift Show resolved Hide resolved
return self.modifier(OnPurchaseStartedModifier(handler: { _ in
handler()
}))
}
Copy link
Contributor

@tonidero tonidero Feb 21, 2024

Choose a reason for hiding this comment

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

Should we mark this one as deprecated as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, good catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added in f5c21b5 and e5b935f

public func presentPaywallIfNeeded(
requiredEntitlementIdentifier: String,
offering: Offering? = nil,
fonts: PaywallFontProvider = DefaultPaywallFontProvider(),
presentationMode: PaywallPresentationMode = .default,
purchaseStarted: PurchaseStartedHandler? = nil,
purchaseStarted: @escaping PurchaseStartedHandler,
Copy link
Member

Choose a reason for hiding this comment

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

@vegaro I'm not certain if the @escaping is breaking changing (I'd have to experiment) but making this non-nullable is a breaking change, isn't it? 😬

If somebody was using this function without purchaseStarted, it will now require them to have purchaseStarted?

RevenueCatUI/View+PresentPaywallFooter.swift Show resolved Hide resolved
RevenueCatUI/View+PresentPaywallFooter.swift Show resolved Hide resolved
@@ -35,13 +36,17 @@ class PurchaseCompletedHandlerTests: TestCase {
.onPurchaseStarted {
started = true
}
.onPurchaseStarted { package in
Copy link
Member

Choose a reason for hiding this comment

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

Does this work for a variable name?! Even though package is a reserved word? 😅

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 know, it doesn't complain so I think so?

public func presentPaywallIfNeeded(
requiredEntitlementIdentifier: String,
offering: Offering? = nil,
fonts: PaywallFontProvider = DefaultPaywallFontProvider(),
presentationMode: PaywallPresentationMode = .default,
purchaseStarted: PurchaseStartedHandler? = nil,
purchaseStarted: @escaping PurchaseStartedHandler,
Copy link
Member

Choose a reason for hiding this comment

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

Did the API tester for this break? That would really let us know, wouldn't it? 🤷‍♂️

@vegaro vegaro enabled auto-merge (squash) February 21, 2024 17:11
@vegaro vegaro merged commit 3442d40 into main Feb 21, 2024
24 checks passed
@vegaro vegaro deleted the purchase-started branch February 21, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:feat A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants