dooboolab-community / react-native-iap

In App Purchase module for React Native!
https://react-native-iap.dooboolab.com
MIT License
2.74k stars 633 forks source link

getProducts and getSubscriptions are undefined and products and subscriptions are empty arrays #2538

Open amiroucheoussama opened 10 months ago

amiroucheoussama commented 10 months ago

Please use the Discussion board if you want to get some help. Please use issues to report bugs.

Description

getProducts and getSubscriptions from useIAP hook return always undefined and products and subscriptions are always empty arrays. Expected Behavior

I am trying to fetch products from apple but i'm getting undefined or empty array, i completed all steps about configuring in app purchases in app store connect, i added product skus. I am expecting to receive an array of my products added earlier in app store connect.

You can take look to screenshots for further explanation about my in app purchases products and how i'm fetching them in my app. screenshots provide used code. Screenshots

Screenshot 2023-09-07 at 12 25 14 PM Screenshot 2023-09-07 at 12 24 43 PM Screenshot 2023-09-07 at 12 24 29 PM

Environment:

To Reproduce Steps to reproduce the behavior:

  1. add in app purchase in app store connect and in make available in xcode
  2. add in app purchase products
  3. try to fetch them from ios app in ios simulator

HINT: my app is not published and noy yet submitted in app store or testflight, i have not uploaded any bundle to app store yet, i'm matching the sku in app store with bundle identifier in xcode.


EDIT: I found that in my agreements section, i have an agreement for free apps, can it be the problem ?

Screenshot 2023-09-08 at 10 44 38 AM
arslantopcu1 commented 10 months ago

same error react-native-iap: 12.10.7 react-native: 0.66.5 Platforms : IOS, simulator

image
amiroucheoussama commented 10 months ago

same error react-native-iap: 12.10.7 react-native: 0.66.5 Platforms : IOS, simulator

image

Have you completed your agreements and banking and tax section ? do you have free pr paid apps ?

arslantopcu1 commented 10 months ago
image

status: Ready to Submit is ok?

amiroucheoussama commented 10 months ago
image

status: Ready to Submit is ok?

how about agreements and banking ? do you have paid apps or free apps ?

Gnative commented 10 months ago

Did you try with the full product id for your SKU. You can see this in the subscriptions -> group page

Screenshot 2023-09-09 at 12 41 31
benminor commented 10 months ago

Getting this same issue, any update here? It was working fine for me, went on vacation, came back and now getting empty arrays for subscriptions and products.

benminor commented 10 months ago

@amiroucheoussama did you manage to find a solution?

ddambrosi90 commented 9 months ago

I’m having the same problem, have you found a solution? @benminor @amiroucheoussama

indranildas19 commented 9 months ago

having the same problem

renatomserra commented 9 months ago

having the same issue on iOS on first load, second attempt works

crrobinson14 commented 9 months ago

Same here. In my case sometimes it works and sometimes not. My connection is definitely initialized - I have a log entry when that happens and that's done at app-start. One thing I noticed is that since it seems to work properly the SECOND time, I just added a useEffect to force it to trigger twice:

  useEffect(() => {
    getAvailablePurchases().catch((e) => console.log('[IAP] Error loading available purchases', e));
    getProducts({skus: SKUS}).catch((e) => console.log('[IAP] Eror loading products', e));
    getSubscriptions({skus: SKUS}).catch((e) => console.log('[IAP] Error loading subscriptions', e));
  }, [getAvailablePurchases, getProducts, getSubscriptions]);

Trim as needed for the functions you use. This seems to kick the system into gear and the useIAP hook helpers return valid product arrays for me after that.

socialappsbrasil commented 9 months ago

I have the same problem

aleksey-mukho commented 9 months ago

+1

ducbinh1995 commented 8 months ago

Same here

Erenner commented 8 months ago

m2 +1

adamsolomon1986 commented 8 months ago

I can confirm calling RNIap.getSubscriptions twice makes it work!! (back to CS101 boyz)

minusleaf commented 7 months ago

Hey all! I had the issue where subscriptions were empty arrays, even after trying to call getSubscriptions twice. Turns out I needed to get the Paid App Agreement signed from App Store Connect. Hope this helps people who skimmed through the instructions on testing like this guy did...

yarenrkmez commented 7 months ago

Although I confirmed the permissions, the products were coming empty array, this problem was fixed when I tried with the real device

GaNiziolek commented 6 months ago

You need the Paid Apps agreement to use IAP image

duongnv1402 commented 5 months ago

Check your storekit config file in xcode scheme

Screenshot 2024-01-29 at 10 28 15

make sure you have choose one

anhtuank7c commented 1 month ago

I need these thing to able to fetch products on iOS

  1. Tax information, banking agreements ✅
  2. Create in-app purchase product, status must be Ready to Submit
  3. From App submission, don't forget to add those products to In-App Purchases and Subscriptions
  4. Add a new Storekit Configuration file that sync with appstore connect ✅
  5. Edit product scheme > Tab Options > Select StoreKit Configuration ✅
  6. use hooks to getProducts({ skus: ['your_product_sku']}) as normal guide ✅

I use Expo to develop app. The funniest thing is I need to do all the step from above to able to make react-native-iap works BUT after that I could completely remove the ios and android folder to generate them again by execute npx expo prebuild --clean, and then just npx expo run ios, it works (even this case the StoreKit is no longer exist in ios folder) That's weird.

Update: The weird thing from above is products cached on device, whenever you remove app and run iOS again you will got an empty array of product.