Error code "null" for everything, are you kidding me?
iOS
Example errors
cancelled
on a simulator (not chargebee's fault)
On Android, details is a dynamic and apparently contains a stringified stacktrace. On iOS, we get a useless message property instead and need to use details to figure out what happened.
The necessary, ugly workaround
We can't display the English, internal(!) error message to the end user and now we seriously need to check if the error message contains specific words to hopefully distinguish them!?
Here's our "solution", but please just provide error codes instead...
try {
return await Chargebee.purchaseProduct(product, uid);
} on PlatformException catch (e) {
// On Android, message will be set (details is a stringified stacktrace)
if (e.message != null) {
// Android: "User pressed back or canceled a dialog" <- no, not a typo, just USA...
if (e.message!.contains("canceled")) return PurchaseResult("", "", PurchaseResultExtension.kCancelled);
}
// On iOS, details will be set instead.
if (e.details != null) {
// iOS: "User cancelled the payment."
if (e.details.toString().contains("cancelled")) {
return PurchaseResult("", "", PurchaseResultExtension.kCancelled);
}
}
// List of known error messages at the time of writing:
// Android:
// - "User pressed back or canceled a dialog"
// - "SDK key not available to proceed purchase"
// iOS:
// - "User cancelled the payment."
// - "Purchase is unavailable due to unknown or unexpected reason. Please try again later."
return PurchaseResult("", "", PurchaseResultExtension.kError);
}
An actual solution
Please provide useful PlatformExceptions with actual error codes that match(!) between Android and iOS.
Android
Example errors
Error code
"null"
for everything, are you kidding me?iOS
Example errors
On Android, details is a dynamic and apparently contains a stringified stacktrace. On iOS, we get a useless
message
property instead and need to usedetails
to figure out what happened.The necessary, ugly workaround
We can't display the English, internal(!) error message to the end user and now we seriously need to check if the error message contains specific words to hopefully distinguish them!?
Here's our "solution", but please just provide error codes instead...
An actual solution
Please provide useful PlatformExceptions with actual error codes that match(!) between Android and iOS.