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.
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.activei"pro"] !== "undefined") {
return true;
}
} catch (e) {
// Error fetching customer info
return false;
}
};