Skip to main content
Solved

Initial launch of App presentPaywallIfNeeded returns what ?


Forum|alt.badge.img+1

I’m trying to understand what this would return if the user is NOT connected to the internet when they first launch the app after a clean install.

 const payWallResult = await RevenueCatUI.presentPaywallIfNeeded({
      requiredEntitlementIdentifier: "pro",
    });

What im suspecting is that it returns PAYWALL_RESULT.NOT_PRESENTED, but this is wrong ,since when you are subscribed and not need the paywall this would be the case as well. So it returns this status if A) you are not connected to the internet (only on clean install) and B) you have a subscription already.

 

This can make users that know this trick - just disable internet and have full access to all features, by just disabling internet for this app. Any advice ?

Best answer by wes_clark

Hi! Yes, if the Internet is offline, the paywall will not be displayed as a connection is necessary to make a purchase. I would recommend directly checking if the necessary entitlement is active within the CustomerInfo in order to distinguish between these two cases instead. Here is our documentation on how the SDK handles caching if you are interested.

View original
Did this post help you find an answer to your question?
This post has been closed for comments

2 replies

wes_clark
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 235 replies
  • Answer
  • March 21, 2024

Hi! Yes, if the Internet is offline, the paywall will not be displayed as a connection is necessary to make a purchase. I would recommend directly checking if the necessary entitlement is active within the CustomerInfo in order to distinguish between these two cases instead. Here is our documentation on how the SDK handles caching if you are interested.


Forum|alt.badge.img+1
  • Author
  • New Member
  • 2 replies
  • March 22, 2024

Thank you - I came up with this solution which now works

I call isSubscribedAndShowPaywall() when I need to access a feature and it will bring up the paywall. Then after the paywall is showed or not - I double check the entitlement and then return if the user can access this or not.

Before I was relying on the paywall result, but this didnt work as restore didnt always work on sandbox and the paywall wasn’t presented at all when offline.

const isSubscribedAndShowPaywall = async () => {
    const payWallResult = await RevenueCatUI.presentPaywallIfNeeded({
      requiredEntitlementIdentifier: "pro",
    });

    //now check if user has entitlement (we cant rely on paywallResult)
    const hasEntitlement = await getEntitlementStatus();

    //warn user that they need internet
    if (isOnline === false && hasEntitlement === false) {
      Alert.alert(
        "Error",
        "This is a pro feature, and you require an internet connection to proceed."
      );
    }

    return hasEntitlement;
  };


const getEntitlementStatus = async () => {
  try {
    const customerInfo = await Purchases.getCustomerInfo();

    if (typeof customerInfo.entitlements.active["pro"] !== "undefined") {
      return true;
    }
  } catch (e) {
    // Error fetching customer info
    return false;
  }
};

 


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