RNIap.getProducts not returning promise on ios
See original GitHub issueVersion of react-native-iap
“react-native-iap”: “^2.3.25”
Version of react-native
“react-native”: “0.57.4”,
Platforms you faced the error (IOS or Android or both?)
IOS
Expected behavior
buyProduct should return promise ( .then() is not call ),
Actual behavior
buyProduct not returning any promise, in android its working fine, .then() call successfully, but in ios its not.
Tested environment (Emulator? Real Device?)
Real Device
Steps to reproduce the behavior
onBuyNowPress() {
this.setState({ loading: true });
RNIap.getProducts(['product_id']).then(success => {
RNIap.buyProduct('product_id').then(purchase => {
console.log("Purchase >>", purchase)
this.setState({
loading: false,
receipt: purchase.transactionReceipt,
});
Alert.alert('Purchase Successful!');
this.props.getPurchase();
}).catch(err => {
console.log(err.code, err.message);
this.setState({ loading: false });
Alert.alert(err.message);
if(err.message === "You already own this item.") {
this.props.getPurchase();
}
})
}).catch(error => {
alert(error);
this.setState({ loading: false });
})
}
In ios i already buy product, so again when i press buy now, i get popup like you already purchase this product. but .then() or .catch() not getting call.
i also tried getAvailablePurchases() method, its always return []
Issue Analytics
- State:
- Created 5 years ago
- Comments:24 (10 by maintainers)
Top Results From Across the Web
react-native-iap - npm
Promise <Subscription[]>, Get a list of subscriptions. Note: With before iOS 11.2 , this method will also return products if they are ...
Read more >react-native-iap getProducts return empty array - Stack Overflow
For those facing this issue with iOS, make sure you finalise the agreements and tax, then make sure to copy and paste this...
Read more >React Native : Subscriptions, In-App Purchases & Service ...
Configure in-app purchase on iTunes Connect (for iOS) ... I've decided to redesign the Purchase Flow to not rely on Promise or Callback...
Read more >RNIap is not working on Android but works in iOS with same ...
getProducts () printed in terminal. Actual behavior Promise is not returned. Error 'billing is not available'. Tested environment (Emulator? Real Device?)
Read more >React-native-iap-badoo NPM | npm.io
In iOS, it will simply call canMakePayments method and return value. getProducts, string[] Product IDs/skus, Promise<Product[]>, Get a list of products ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@hyochan i finally solved the issue… problem is when i first test i didnt write this line
await RNIap.finishTransaction();
in .then() method. i added it afterward. that was the problem, solution is i need to clear transaction(await RNIap.clearTransaction();
), and it work.Thanks again for your support n for this great library.
Could you try
2.4.0-beta4
?