Skip to content

Add PaywallView.onRequestedDismissal modifier and option to pass dismissRequestedHandler to PaywallViewController#3738

Merged
vegaro merged 20 commits into
mainfrom
add-requested-dismissal
Mar 13, 2024
Merged

Add PaywallView.onRequestedDismissal modifier and option to pass dismissRequestedHandler to PaywallViewController#3738
vegaro merged 20 commits into
mainfrom
add-requested-dismissal

Conversation

@vegaro

@vegaro vegaro commented Feb 28, 2024

Copy link
Copy Markdown
Member

@vegaro vegaro changed the title don't automatically dismiss and call dismiss handler Don't automatically dismiss and add onRequestedDismissal Feb 28, 2024
@vegaro vegaro added the pr:feat A new feature label Feb 28, 2024
@vegaro vegaro changed the title Don't automatically dismiss and add onRequestedDismissal PaywallViewController: option to not automatically dismiss and add onRequestedDismissal Feb 28, 2024
@vegaro vegaro force-pushed the add-requested-dismissal branch from ab3b293 to 6200b95 Compare February 29, 2024 16:38
@vegaro vegaro requested a review from a team February 29, 2024 19:12
@vegaro vegaro marked this pull request as ready for review February 29, 2024 19:12

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Comment thread RevenueCatUI/PaywallView.swift

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking good! Just a couple of comments

Comment thread RevenueCatUI/UIKit/PaywallViewController.swift Outdated
Comment thread RevenueCatUI/UIKit/PaywallViewController.swift Outdated
fonts: DefaultPaywallFontProvider(),
displayCloseButton: false)
displayCloseButton: false,
dismissalRequest: nil)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

hmmm, yes. I think it makes sense, I will add it to PaywallFooterViewController

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

@vegaro vegaro Mar 12, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, I think we do call it in Android on finishing purchasing...

I will make the change

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just that question about the footer. Otherwise looks good!

fonts: PaywallFontProvider,
displayCloseButton: Bool = false
displayCloseButton: Bool = false,
dismissalRequest: ((_ controller: PaywallViewController) -> Void)? = nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm while I think we need to add it to the other constructors here, why do we add it to the unavailable constructor?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didn't notice sorry, will remove

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh actually, this one is overriden from PaywallViewController, so it's required :/

@joshdholtz joshdholtz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Small thought on naming but otherwise this looks good!

Comment thread RevenueCatUI/UIKit/PaywallViewController.swift Outdated
Comment thread RevenueCatUI/UIKit/PaywallViewController.swift Outdated
@vegaro vegaro requested review from joshdholtz and tonidero March 12, 2024 19:52
@vegaro vegaro force-pushed the add-requested-dismissal branch from 7285825 to d814cbc Compare March 13, 2024 11:23
@vegaro vegaro enabled auto-merge (squash) March 13, 2024 13:39
@vegaro

vegaro commented Mar 13, 2024

Copy link
Copy Markdown
Member Author

@joshdholtz can you take a look? I can't merge until I get your approval 😄

@joshdholtz joshdholtz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 💪

@vegaro vegaro merged commit 8bc8a01 into main Mar 13, 2024
@vegaro vegaro deleted the add-requested-dismissal branch March 13, 2024 13:41
@vegaro vegaro changed the title PaywallViewController: option to not automatically dismiss and add onRequestedDismissal Add PaywallView.onRequestedDismissal modifier and option to pass dismissRequestedHandler to PaywallViewController Mar 13, 2024
vegaro pushed a commit that referenced this pull request Mar 13, 2024
**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)
vegaro added a commit to RevenueCat/purchases-hybrid-common that referenced this pull request Mar 14, 2024
vegaro added a commit to RevenueCat/react-native-purchases that referenced this pull request Mar 14, 2024
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.
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