Add PaywallView.onRequestedDismissal modifier and option to pass dismissRequestedHandler to PaywallViewController#3738
Conversation
onRequestedDismissal
onRequestedDismissalonRequestedDismissal
ab3b293 to
6200b95
Compare
a244718 to
c2365a6
Compare
05ded5a to
3c0f473
Compare
tonidero
left a comment
There was a problem hiding this comment.
Looking good! Just a couple of comments
| fonts: DefaultPaywallFontProvider(), | ||
| displayCloseButton: false) | ||
| displayCloseButton: false, | ||
| dismissalRequest: nil) |
There was a problem hiding this comment.
Hmm I think we should still accept a dismissalRequest parameter for the footer, since there might be a successful purchase? Alternatively, we can just devs use the purchaseCompleted callback, which would be called in the same location... But not sure if we want to be consistent with that behavior between the full screen and footer.
There was a problem hiding this comment.
hmmm, yes. I think it makes sense, I will add it to PaywallFooterViewController
There was a problem hiding this comment.
Ok... so I added it, but the callback is not being called because there's this code in PaywallView
if self.mode.isFullScreen, purchased {
Logger.debug(Strings.dismissing_paywall)
guard let onRequestedDismissal = self.onRequestedDismissal else {
self.dismiss()
return
}
onRequestedDismissal()
}
I am going to see what happens in Android... but if we don't call the onDismiss in Android, I think we shouldn't do it here either
There was a problem hiding this comment.
Ok, I think we do call it in Android on finishing purchasing...
I will make the change
tonidero
left a comment
There was a problem hiding this comment.
Just that question about the footer. Otherwise looks good!
| fonts: PaywallFontProvider, | ||
| displayCloseButton: Bool = false | ||
| displayCloseButton: Bool = false, | ||
| dismissalRequest: ((_ controller: PaywallViewController) -> Void)? = nil |
There was a problem hiding this comment.
Hmm while I think we need to add it to the other constructors here, why do we add it to the unavailable constructor?
There was a problem hiding this comment.
I didn't notice sorry, will remove
There was a problem hiding this comment.
oh actually, this one is overriden from PaywallViewController, so it's required :/
joshdholtz
left a comment
There was a problem hiding this comment.
Small thought on naming but otherwise this looks good!
7285825 to
d814cbc
Compare
|
@joshdholtz can you take a look? I can't merge until I get your approval 😄 |
onRequestedDismissal PaywallView.onRequestedDismissal modifier and option to pass dismissRequestedHandler to PaywallViewController
**This is an automatic release.** ### RevenueCatUI * Add `PaywallView.onRequestedDismissal` modifier and option to pass `dismissRequestedHandler` to `PaywallViewController` (#3738) via Cesar de la Vega (@vegaro) ### Bugfixes * [EXTERNAL] Fix Typos in ReceiptStrings.swift (#3756) via @nickkohrn (#3760) via Cesar de la Vega (@vegaro) ### Other Changes * Pin xcbeautify version for xcode 14 tests (#3759) via Cesar de la Vega (@vegaro) * PaywallsTester: fix compilation (#3753) via Andy Boedo (@aboedo)
Depends on: - RevenueCat/purchases-ios#3708 - RevenueCat/purchases-ios#3738 - RevenueCat/purchases-hybrid-common#746 With this PR, there's a change in functionality in the way the dismissal of the paywall works in iOS. In iOS I noticed there was a bug that prevented the `onDismiss` callback from getting called when using `PaywallView` after dismissal of the paywall, and I also noticed that the paywall was getting automatically dismissed. In Android, I noticed the behavior was different, and the paywall wouldn't close by itself and the `onDismiss` would be called, so the `PaywallView` could be _dismissed_ by the developer. Taking into account the way React Native views work, I think the developer should have the responsability of not showing the paywall (dimissing it). So I consider Android implemntation's the correct one. Those PRs (RevenueCat/purchases-ios#3738 and RevenueCat/purchases-hybrid-common#746) make some changes in the way iOS behaves, so if the view is created from `PaywallProxy`, which is what React Native uses to create a `PaywallView` the view wouldn't close itself after the close button is pressed (or a successful purchase happens). It's a change in behavior, but I think it's a actually something we overlooked in iOS implementation's. Also, take into account that `PaywallView` in iOS used to do `self.dismiss`, which I believe would only work if the PaywallView in React Native is being presented using something like Navigator, where the dismiss event would bubble up and close the container controller.
Please read RevenueCat/react-native-purchases#913