dooboolab-community/react-native-iap

Empty Array after using getProducts()

mkamadeus opened this issue · 7 comments

I'm currently having a problem when using this library related to the getProducts() function.

Version of react-native-iap

I'm using version 4.5.0.

Version of react-native

I'm using version 0.63.1.

Platforms you faced the error (IOS or Android or both?)

Faced this problem on Android.

Expected behavior

initConnection() : Showing true as a result.
getProducts() : Getting the list of active items registered on Google Play Developer Console.

Actual behavior

initConnection() : Showing true as a result.
getProducts() : Getting an empty array :(

Tested environment (Emulator? Real Device?)

I've tested this using a real device, as suggested by other issues.

Steps to reproduce the behavior

  1. Add the BILLING permission to AndroidManifest.xml as follows:

In the src/debug/ and src/main/ folder I added both of this line.

<uses-permission android:name="com.android.vending.BILLING" />
  1. Making a simple button using React Native, then have the button do an onPress action.
  2. Create the onPress function to be tested. I created this to test:
  const itemSkus = Platform.select({
    android: ['storeticket_0', 'storeticket_1', 'storeticket_2'],
  });
  ...
  const handleSubscription = async () => {
    try {
      setProcessing(true);

      await initConnection()
        .then(async (conn) => {
          console.log(conn); // Expected and Actual outputs true!
          return await getProducts(itemSkus);
        })
        .then((test) => {
          console.log(test); // Outputs an empty array (on my device)
          setProcessing(false);
        });
    } catch (err) {
      setProcessing(false);
    }
  };

My SKUs:
image

  1. Upload the APK file after building to the Play Console.

What I've been doing is following several guides and issues all over the place, but I have no success with it :( Here's what I've tried so far:

  • Some people said that I'm required to wait several hours/days for the products to register on the console (Source: this SO post). Waited for almost a week, still doesn't work.
  • Fixed my codebase so the package name matches the package name on the Play Console, but still no luck.

Did I do something wrong? Or maybe the review time is just very long in my case? As in the console it's being announced that they are currently taking longer to review apps. My current state of the app on the Play Console:
image

What else do I need to do and setup in order to test for at least getting the in app products and for further testing (like testing the payment system)? Thanks in advance! :)

Hi there, i dont see anything wrong after looking over your code.
However I would suggest you check the status of your app on Google Play Console. We need google to complete its pending review before the API for your store items to be available for you to fetch.

It could take couple days though its best to wait and work on some other tasks now.

@kennguyen1506 I see, thanks for the response. I'll wait for the status to be changed. I'll report back when it does.

Sorry for the late reply, can confirm that my code already works and it is required to wait your app to be approved in the Play Console. Thanks for the help!

@mkamadeus @kennguyen1506 I am using react-native-iap for iOS the latest version 12.10.5 and I am getting empty array? is it required to get IAP plans approve on the App Store only then I can get products. But if I will do this how can I test my app to do code further without getting this in my first version?

@mkamadeus @kennguyen1506 I am using react-native-iap for iOS the latest version 12.10.5 and I am getting empty array? is it required to get IAP plans approve on the App Store only then I can get products. But if I will do this how can I test my app to do code further without getting this in my first version?

Exactly...this is confusing. In iOS the products are available before any approval. Seems Google has the cart before the horse here?

Looking at the setup in Google Play Console it looks like they will approve for a closed track where you can do the testing before going live...I guess I'll find out in a minute lol

any updates on this issue? Seems Google still wants to approve for a closed track to test