All files / lib paywall.ts

100% Statements 6/6
100% Branches 4/4
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16              5x 5x 3x   2x 2x      
import RevenueCatUI, { PAYWALL_RESULT } from "react-native-purchases-ui";
 
/**
 * Present the RevenueCat dashboard-configured paywall. Returns true if the user
 * came out subscribed (purchased or restored). One partner pays, both unlock.
 */
export async function presentPaywall(): Promise<boolean> {
  try {
    const result = await RevenueCatUI.presentPaywall();
    return result === PAYWALL_RESULT.PURCHASED || result === PAYWALL_RESULT.RESTORED;
  } catch (e) {
    if (__DEV__) console.warn("[paywall] presentPaywall failed", e);
    return false;
  }
}