Why can't I query available in-app purchases

Viewed 452

I have a React Native Expo project. I'm using this library. - for in app payments on iOS.

The issue is, my query for available in-app purchases is returning nothing.

While the purchases can't be retrieved, I can't build any payments.

Notes:

  • I'm testing RN app through the Expo iOS client
  • In app purchases are ready to submit in Apple connect
  • App has all data complete in Apple connect, but is not submitted yet

Here is the code. It's copypaste from the GitHub documentation

 try {
        await InAppPurchases.connectAsync();
        const items = Platform.select({
          ios: ["basic", "medium", "best"],
          android: [],

        });
        // Retrieve product details
        const getPurchasable = await InAppPurchases.getProductsAsync(items);
        const { responseCode, results } = getPurchasable;


2 Answers

If you have an unaccepted Paid applications agreement, you will not be able to receive purchases. Also, you can try to use iTunes Sandbox account

tldr; getProductsAsync does not resolve on an ios simulator

Old question, but I ran into the same issue, so it's worth answering:

  1. expo-in-app-purchases only works in the bare workflow, so make sure you're using that
  2. Whilst the expo documentation states that "...in-app purchases require physical devices to work on both platforms and therefore cannot be tested on simulators." in reality it's more complicated than this as some methods work just fine on simulators / emulators.

On Android most, if not all, methods work in the emulator. You can fetch products with getProductsAsync, but attempting to purchase them with purchaseItemAsync returns an error (unless you are signed in to a Google account on the emulator)

On iOS fewer methods work in the simulator. While connectAsync works, getProducts never resolves in a simulator.

Therefore, in order for getProducts to resolve, you need to test on a physical device. Either using a Sandbox account, or with TestFlight.

Related