IOs can purchase only if i invoke getSubscriptions first
marcosmartinez7 opened this issue · comments
Version of react-native-iap
2.2.2
Platforms you faced the error (IOS or Android or both?)
IOS
Expected behavior
Should purchase the subscription
Actual behavior
I can only purchase if i invoke getSubscriptions first, otherwise, i get Invalid Product ID
Tested environment (Emulator? Real Device?)
Real device
Steps to reproduce the behavior
This works:
await RNIap.initConnection();
let subs =await RNIap.getSubscriptions(itemSkus);
console.warn(subs);
let purchase = await RNIap.buySubscription("someone");
This doesnt (throws invalid product id):
await RNIap.initConnection();
let purchase = await RNIap.buySubscription("someone");
On android works fine both
In iOS, initConnection doesn't do anything. You should get subscription / production first.
I think it's the right response.
If youre right, then the buySubscription is checking the valid products in some data retrieved by getSubscriptions previously.. y though that buySubscription was checking against the AppleStore API. So i guess the module is handling the list of available products internally, in the app memory.
Also, in Android i can purchase without invoke the getSubscriptions, so if youre right the API docs are a little bit confusing
@dooboolab can you confirm that this is the correct behaviour?
Thanks
@marcosmartinez7
initConnection
is checking whether you can purchase in ios
unlike in Android which actually starts the billing
service.
Yes, in ios, you should always fetchProducts
first. You can see more info here.
Thanks!
It tooks me a lot of time to realice that was the problem, because the "Invalid product id" has a lot of common causes :P
it would be cool to add this to the docs too
I've added Q & A section in readme. Will close this for now.