How to use the react-native-iap.getProducts function in react-native-iap

To help you get started, we’ve selected a few react-native-iap 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 Musicoin / app / components / product / ProductModal.js View on Github external
async componentDidMount() {
    try {
      const products = await RNIap.getProducts(itemSkus);
      products.sort(this.compare);
      this.setState({products});
      console.log(products);
    } catch (err) {
      console.log(err); // standardized err.code and err.message available
    }
  }
github HenryQuan / WoWs-Info-Re / WoWsInfo / src / component / common / Donation.js View on Github external
async componentDidMount() {
    if (!GITHUB_VERSION) {
      try {
        const products = await RNIap.getProducts(itemSkus);
        // Do this just to ensure that all IAPs are available
        await RNIap.consumeAllItems();
        products.sort((a, b) => a.price.localeCompare(b.price));
        this.setState({products});
      } catch(err) {
        console.warn(err); // standardized err.code and err.message available
      }
    }
  }
github esteemapp / esteem-mobile / src / containers / inAppPurchaseContainer.js View on Github external
_getItems = async () => {
    const { skus } = this.props;

    try {
      const products = await RNIap.getProducts(skus);

      products.sort((a, b) => parseFloat(a.price) - parseFloat(b.price)).reverse();
      await this.setState({ productList: products });
    } catch (err) {
      bugsnag.notify(err);
      Alert.alert(
        `Fetching data from server failed, please try again or notify us at info@esteem.app
          ${err.message.substr(0, 20)}`,
      );
    }

    await this.setState({ isLoading: false });
  };
github birkir / hekla / src / screens / settings / Donate.tsx View on Github external
async fetchData() {
    this.loading = true;
    try {
      const status = await RNIap.prepare();
      this.products = await RNIap.getProducts(SKUs);
    } catch (err) {
      Sentry.captureException(err);
    }
    this.loading = false;
  }
github raindropio / mobile / src / screens / settings / pro / buy / module.js View on Github external
const products = {
        'io.raindrop.pro.1month': {
            title: t.s('oneMonth'),
            sort: 0
        },
        'io.raindrop.pro.3month': {
            title: t.s('threeMonth'),
            sort: 1
        },
        'io.raindrop.pro.1year': {
            title: _.capitalize(t.s('year'))+' (-20%)',
            sort: 2
        }
    }
    
    let found = await RNIap.getProducts(Object.keys(products))
    found = found.map(product => ({
        ...product,
        sort: products[product.productId].sort,
        localizedTitle: products[product.productId].title
    }))
    found = _.sortBy(found, ({sort})=>sort)

    return found
}