I am executing the following code to fetch available products from the iTunes store upon user opening the app:
getProducts() {
const productIds = ["svs_halftyer", "svs_monthly"]; // These are dummy ids
this.iap
.getProducts(productIds)
.then((res) => {
console.log(res);
})
.catch((error) => {
if (this.getProductsRetryCount < 20) {
this.getProductsRetryCount += 1;
setTimeout(() => {
this.getProducts();
}, 500);
} else {
this.saveGetProductsError(error);
}
});
}
However, some of my users (approximately 50) encounter an error that results in an empty object
{} in the catch block of the function. These exceptions are logged to my backend, where I've counted the occurrences. Despite retrying the function up to 20 times in the case of an error, the issue persists.
Another error received by users is as follows:
{"errorMessage": "An unknown error occurred", "errorCode": 0}
This particular error has been reported around 50 times.
After consulting Apple's documentation Apple Documentation on SKError.Code.unknown which mentions that the SKError.Code.unknown error may sometimes be resolved by retrying the request, I implemented a retry mechanism:
However, I have not been unable to identify the cause of these issues. I considered whether it might be due to In-App Purchases being disabled by the user, as detailed here: Use Screen Time to turn off in-app purchases
Has anyone encountered similar errors or have insights on what might be causing these issues and how to effectively handle them?