Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// This is not a requirement on iOS
const wasAcknowledged = await maybeAcknowledgePurchaseAndroid(
purchase,
)
if (!wasAcknowledged) {
// TODO: what do we do in this case? the purchase has still gone through but will
// be cancelled in a few days
onWarning('Purchase was not acknowledged')
}
setCurrentSubscriptionInfo(info)
onPurchase(info)
},
)
purchaseErrorSubscription.current = purchaseErrorListener(onError)
return () => {
const updateListener = purchaseUpdateSubscription.current
updateListener && updateListener.remove()
const errorListener = purchaseErrorSubscription.current
errorListener && errorListener.remove()
}
}, [onPurchase, onWarning, onError])
if (fetchData) {
fetchData();
}
})
.catch(err =>
bugsnag.notify(err, report => {
report.metadata = {
data,
};
}),
);
}
});
this.purchaseErrorSubscription = purchaseErrorListener(error => {
if (get(error, 'responseCode') === '3' && Platform.OS === 'android') {
Alert.alert(
intl.formatMessage({
id: 'alert.warning',
}),
intl.formatMessage({
id: 'alert.google_play_version',
}),
);
} else if (get(error, 'responseCode') !== '2') {
Alert.alert(
intl.formatMessage({
id: 'alert.warning',
}),
error.debugMessage,
);