react-native-iap icon indicating copy to clipboard operation
react-native-iap copied to clipboard

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

Open amiroucheoussama opened this issue 1 year ago • 21 comments

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:

  • react-native-iap: 12.10.7
  • react-native: 0.71.8
  • Platforms (iOS, Android, emulator, simulator, device): IOS, simulator

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

amiroucheoussama avatar Sep 07 '23 09:09 amiroucheoussama

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

image

arslantopcu1 avatar Sep 08 '23 05:09 arslantopcu1

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 ?

amiroucheoussama avatar Sep 08 '23 07:09 amiroucheoussama

image

status: Ready to Submit is ok?

arslantopcu1 avatar Sep 08 '23 10:09 arslantopcu1

image status: Ready to Submit is ok?

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

amiroucheoussama avatar Sep 08 '23 13:09 amiroucheoussama

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

Gnative avatar Sep 09 '23 10:09 Gnative

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 avatar Sep 11 '23 15:09 benminor

@amiroucheoussama did you manage to find a solution?

benminor avatar Sep 11 '23 18:09 benminor

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

ddambrosi90 avatar Sep 18 '23 07:09 ddambrosi90

having the same problem

indranildas19 avatar Sep 19 '23 15:09 indranildas19

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

renatomserra avatar Sep 30 '23 10:09 renatomserra

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.

crrobinson14 avatar Oct 03 '23 22:10 crrobinson14

I have the same problem

socialappsbrasil avatar Oct 04 '23 18:10 socialappsbrasil

+1

aleksey-mukho avatar Oct 08 '23 19:10 aleksey-mukho

Same here

ducbinh1995 avatar Oct 23 '23 15:10 ducbinh1995

m2 +1

Erenner avatar Nov 08 '23 21:11 Erenner

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

adamsolomon1986 avatar Nov 09 '23 16:11 adamsolomon1986

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...

minusleaf avatar Nov 22 '23 03:11 minusleaf

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

yarenrkmez avatar Dec 06 '23 19:12 yarenrkmez

You need the Paid Apps agreement to use IAP image

GaNiziolek avatar Jan 04 '24 17:01 GaNiziolek

Check your storekit config file in xcode scheme Screenshot 2024-01-29 at 10 28 15

make sure you have choose one

duongnv1402 avatar Jan 29 '24 03:01 duongnv1402

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.

anhtuank7c avatar May 12 '24 13:05 anhtuank7c