Skip to main content
Question

Paywall Question, Close paywall programmatically

  • January 31, 2025
  • 3 replies
  • 43 views

Forum|alt.badge.img+1

I am using RevenueCatUI.presentPaywall to display Paywall on ANDROID, How I can close paywall by auto when user make Pruchases process, the Paywall close just if user click on X icon, I need to close it automatically by RevenueCatUI SDK

This post has been closed for comments

3 replies

Forum|alt.badge.img+8
  • RevenueCat Staff
  • 579 replies
  • February 4, 2025

Hi, when using the RevenueCatUI.presentPaywall() to show the paywall it should dismiss when the purchase is completed. Can you please share with me your paywall code and the version of our SDK you are using? Additionally can you enable RevenueCat debug logs and send those for when a user makes a purchase? See our docs here.


Forum|alt.badge.img+1

Hello ​@Helen Fernety ,

thats the code we using:

const result = await RevenueCatUI.presentPaywall({
displayCloseButton: true,
fontFamily: null, // Replace with your custom font family if needed
});

console.log('Paywall result:', result);

if (result === PAYWALL_RESULT.PURCHASED) {
const modal: CustomModalProps = {
headerText: 'Welcome',
bodyText: 'Thank you.',
primaryButtonText: 'OK',
onPrimaryPress() {
dispatch(closeAlert());
},
};

dispatch(setSubscribeStatus({ isActive: true, showPaywall: false }));

}

the modal dismiss just when user click in X icon, not when user finish the pay process,

as a developer I can tell you the code stack on this line 
const result = await RevenueCatUI.presentPaywall({

displayCloseButton: true,

fontFamily: null, // Replace with your custom font family if needed

});


until the user click on X icon and the code resume and make the If check.
 

"react-native-purchases": "8.5.0",

"react-native-purchases-ui": "8.5.0",

Thanks


Forum|alt.badge.img+8
  • RevenueCat Staff
  • 579 replies
  • February 12, 2025

Hi, thank you for sharing your code. I noticed you also have a support ticket on this and have responded there as well. I will repeat that here:

 I noticed you have used if (result === PAYWALL_RESULT.PURCHASED), incase there is a type issue with this, I recommend instead using switch cases as follows in our code sample:

async function presentPaywall(): Promise<boolean> {
    // Present paywall for current offering:
    const paywallResult: PAYWALL_RESULT = await RevenueCatUI.presentPaywall();
    // or if you need to present a specific offering:
    const paywallResult: PAYWALL_RESULT = await RevenueCatUI.presentPaywall({
        offering: offering // Optional Offering object obtained through getOfferings
    });

    switch (paywallResult) {
        case PAYWALL_RESULT.NOT_PRESENTED:
        case PAYWALL_RESULT.ERROR:
        case PAYWALL_RESULT.CANCELLED:
            return false;
        case PAYWALL_RESULT.PURCHASED:
        case PAYWALL_RESULT.RESTORED:
            return true;
        default:
            return false;
    }
}

 
Can you try that and let me know if it works? If not then can you please provide a more comprehensive code sample so I can see more if what is happening here – I want to check if you have other components that might be impact this? 
 
I can also see you are showing a popup while dismissing a parent view, can you check if the compiler gives any issue/warning while running it?
 

For future replies let us continue in the internal ticket to keep everything in one spot.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings