react-native-iap: getProducts and getSubscriptions returns empty array
Version of react-native-iap
3.4.11
Version of react-native
0.59.10
Platforms you faced the error (IOS or Android or both?)
Currently, I’m only working on iOS.
Expected behavior
Should see auto-renewable subscriptions
Actual behavior
Receiving an empty array:
Tested environment (Emulator? Real Device?)
Mainly tested in the Simulator (Although, I tried on a real device yesterday and it was still empty)
Steps to reproduce the behavior
So to clarify, I originally believed it to be because I had not finalised a tax form in the Agreements, Tax and Banking section of iTunes connect:
However, this has now been completed:
I have created two products with the product ids artistsannual and artistmonthly. My bundle id is com.iynk.iynk.
They are both “Ready to Submit”.
My code:
const subscriptionSKUs = Platform.select({
ios: ['artistmonthly', 'artistannual'],
android: [''],
});
class Upsell extends React.Component {
.
.
.
async componentDidMount() {
try {
const result = await RNIap.initConnection();
console.log('result', result);
const subscriptions = await RNIap.getSubscriptions(subscriptionSKUs);
console.log('subscriptions', subscriptions);
const products = await RNIap.getProducts(subscriptionSKUs);
console.log('products', products);
.
.
.
} catch (e) {
console.log('Error handling in Upsell componentDidMount', e);
}
}
.
.
.
}
The response is:
- result:
true - subscriptions:
[] - products:
[]
I have run react-native link react-native-iap.
I have also tried to implement revenuecat: https://github.com/RevenueCat/react-native-purchases Which is getting the Entitlements but not the products?
Do I need to “Submit the App” before Subscriptions and Products show up? How do you work on development products if this is the case?
I’m very stuck… Thanks in advance everyone!
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 30 (2 by maintainers)
Ok, I have resolved the problem with the use of this StackOverflow post: https://stackoverflow.com/questions/7947805/ios-in-app-purchase-no-products-received/11707704#11707704
The issue was that my bundleID was auto-created by react-native:
org.reactjs.native.example.xxx. I had to change to be the correct one in all relevant files.@Akshay-Chhikara Thank you for your reply. it works i just have to wait between the moment of its ready to submit and to getProducts.
For all just try to wait at least 24h
I solved it! I am using these versions,
react-native-iap: ^4.3.0react-native: 0.60.5just do it like this
I know most fixes have been mentioned here, but it seems like I ran into every possible issue to cause an empty product response. Since there were so many possibilities, here is a collective checklist:
What to Check Locally:
What to Check for Production with iOS (App Store Connect):
There are so many possible issues, I really hope this helps someone else.
*I was really surprised you could pass undefined to getProducts. Is there any reason this method needs to fail silently when the param is undefined? The fact I had it setup incorrectly after a transition from the old RNIAP setup, makes me wonder if it could be a possible common issue.
For me, On simulator it worked after adding store-kit configuration under schema. Only thing it will not work on simulator is receipt validation as simulator not giving proper receipt, but it worked on actual device for me
This was so helpful thank you!
@MutableLoss thanks for reply Issue is fixed i am using store kit configuration file so response is not coming of app store connect product Id’s
@selimmidikoglu Sweet ! Changing my bundle id did the trick ! Awesome !
So basically there is no way to test in app purchases by having dev / staging / release environments with different bundle ids.
It should be written somewhere it’s not obvious at all I spent 3 days on this issue.
@bulby97 There were tons of
First thing was to check if all subscriptions were on stage ‘Ready to Submit’.
Second thing was to fill all the required things on itunnesconnect Agreement, Tax, Banking part. This part was kinda difficult because address field can not be filled with coorect address. You just need to submit 5 times. Apple is really interesting company.
I changed bundle ids in both xcode and itunnes connect. Than I tried to run app on real device.
Than boom my in app purchases was there.
As I see the problem genrally lie beneath by missing one step in configuration state. There is nothing related with code.
Hi, @alexpchin I am having this same issue for 4 hours now and don’t know what to do. My bundleID was also created by RN. What exactly did you change to make it work??