react-native-iap: RNIap.getProducts not returning promise on ios
Version 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 []
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 24 (10 by maintainers)
Commits related to this issue
- Release 2.4.0-beta4 Fixes for #341 putting async wrapper back. — committed to dooboolab-community/react-native-iap by hyochan 6 years ago
@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?