Empty results from getProductsAsync

  1. SDK Version: 36.0.0
  2. Platforms(Android/iOS/web/all): iOS

I’ve ejected to the bare project and implemented all required settings for in-app purchases. On the project start I call InAppPurchases.connectAsync(), then when I need to ask for all my products I do the next:

const { responseCode, results } = await InAppPurchases.getProductsAsync([‘myProductId’]);

    if (responseCode === InAppPurchases.IAPResponseCode.OK) {
        console.log('get in app products results ===> ', results);
        this.setState({ inApps: results });

I enter the case and get an empty Array in the log.

How can I trace what’s wrong? I’m using sandbox tester account as it was said in the docs, I’ve added all required settings, the product ID is correct, why can I get empty array here?

Double-check that your in-app products are all set up within Apple’s App Store Connect web interface, i.e. none of them are in “Missing Metadata” state, and that the product IDs match exactly. Also check that your bare app has the in-app purchases entitlement added in the XCode project settings “Signing & Capabilities” section. And finally, try different ways of running the app on a device. Often the in-app purchase code doesn’t work normally if run in “Debug” mode. For best results, archive the project and install it using Ad Hoc distribution (or TestFlight).

Also, I’ve seen this error happen randomly in production even when everything else is working fine. I think it’s related to network connection errors, i.e. the phone cannot reach Apple’s servers to query the product data.

You need to pass the skus of the products you wish to retrieve.

const { responseCode, results } = await InAppPurchases.getProductsAsync(['coins_for_app']);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.