How to use the react-native-purchases.getOfferings function in react-native-purchases

To help you get started, we’ve selected a few react-native-purchases examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RevenueCat / react-native-purchases / example / app / screens / UpsellScreen.js View on Github external
async componentDidMount() {
    try {
      this.purchaserInfoUpdateListener = (info) => {
        checkIfPro(info, this.props.navigation);
      };
      this.shouldPurchasePromoProduct = async deferredPurchase => {
        this.deferredPurchase = deferredPurchase;
      };
      Purchases.addPurchaserInfoUpdateListener(this.purchaserInfoUpdateListener);
      Purchases.addShouldPurchasePromoProductListener(this.shouldPurchasePromoProduct);
      const offerings = await Purchases.getOfferings();
      // eslint-disable-next-line no-console
      console.log(JSON.stringify(offerings));
      this.setState({
        offerings,
        proAnnualPrice: `Buy Annual w/ Trial ${
          offerings.current.annual.product.price_string
        }`,
        proMonthlyPrice: `Buy Monthly w/ Trial ${
          offerings.current.lifetime.product.price_string
        }`
      });
    } catch (e) {
      // eslint-disable-next-line no-console
      console.log("Error handling");
    }
  }