Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOs can purchase only if i invoke getSubscriptions first #283

Closed
marcosmartinez7 opened this issue Oct 8, 2018 · 6 comments
Closed

IOs can purchase only if i invoke getSubscriptions first #283

marcosmartinez7 opened this issue Oct 8, 2018 · 6 comments
Labels
📱 iOS Related to iOS ❓ question Further information is requested

Comments

@marcosmartinez7
Copy link

marcosmartinez7 commented Oct 8, 2018

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

@JJMoon
Copy link
Contributor

JJMoon commented Oct 9, 2018

In iOS, initConnection doesn't do anything. You should get subscription / production first.
I think it's the right response.

@JJMoon JJMoon added ❓ question Further information is requested 📱 iOS Related to iOS labels Oct 9, 2018
@marcosmartinez7
Copy link
Author

marcosmartinez7 commented Oct 9, 2018

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

@marcosmartinez7
Copy link
Author

@dooboolab can you confirm that this is the correct behaviour?

Thanks

@hyochan
Copy link
Owner

hyochan commented Oct 10, 2018

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

@marcosmartinez7
Copy link
Author

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

@hyochan
Copy link
Owner

hyochan commented Oct 10, 2018

I've added Q & A section in readme. Will close this for now.

@hyochan hyochan closed this as completed Oct 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📱 iOS Related to iOS ❓ question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants