This behaviour has changed recently in my app without any code changes that would cause that as far as I can tell.
When the app is opened for the first time after installation on iOS, it usually (but not always) will prompt the user to purchase a subscription after purchaseItemAsync
is called. However, when the subscription you’ve purchased expires and the app prompts you to buy it again, after calling purchaseItemAsync
again the promis never resolves, and the purchasing prompt doesn’t pop up for the user.
async componentDidMount() {
await InAppPurchases.connectAsync(); <-- This works
InAppPurchases.setPurchaseListener(({ responseCode, results }) => {
if (responseCode === InAppPurchases.IAPResponseCode.OK) {
results.forEach(async (purchase) => {
if (!purchase.acknowledged) {
this.subscribe(purchase);
}
});
try {
const { responseCode: appResponseCode, results: appResults } = await InAppPurchases.getProductsAsync(items); <-- This works
responseCode = appResponseCode;
results = appResults;
} catch (err) {
responseCode = 'fail';
results = [];
}
if (responseCode === InAppPurchases.IAPResponseCode.OK) {
this.setState({ items: results });
}
}
...
<Button
title={`Buy ${item.price}`}
onPress={() => {
InAppPurchases.purchaseItemAsync(item.productId); <-- This promise never resolves
}}
/>
React Native: 0.61.4
Expo: 36.0.0
Expo In App Purchases: 8.0.0