flutter_iap
flutter_iap copied to clipboard
android: fetchProducts() never returns on error
My code works :
IAPResponse response = await FlutterIap.fetchProducts(productIds);
Except in the case where there is a problem during the request (for example when trying the code on an emulator and there is no IAP). In this case we get the error text :
D/BillingManager( 3081): Destroying the manager.
D/BillingManager( 3081): Creating Billing client.
D/BillingManager( 3081): Starting setup.
D/BillingManager( 3081): Setup finished. Response code: 3
But the IAPResponse is never returned so my code is left hanging. It would be better if it returned with the status code so that I can do :
IAPResponse response = await FlutterIap.fetchProducts(productIds);
if(response.status==3) return false;
Thanks. I'll add that sometime soon.
Perhaps just return a empty product list?
It should also say why the list is empty if there is an error
@JackAppDev currently trying to get all error codes merged from iOS & Android into this master enum:
// Defines the response status for a IAP operation.
enum IAPResponseStatus {
// All went well, see the other fields for response details.
ok = 0;
// Fatal error during the API action.
error = 1;
// (iOS only) Library user needs to fetch the list of products from the store first.
emptyProductList = 2;
// In-App purchases not available (device or policy constraints etc).
disabled = 3;
/// User pressed back or canceled a dialog
userCanceled = 4;
/// Network connection is down
serviceUnavailable = 5;
/// Billing API version is not supported for the type requested
billingUnavailable = 6;
/// Requested product is not available for purchase
itemUnavailable = 7;
/// Invalid arguments provided to the API. This error can also indicate that the application was
/// not correctly signed or properly set up for In-app Billing in Google Play, or does not have
/// the necessary permissions in its manifest
developerError = 8;
/// Failure to purchase since item is already owned
itemAlreadyOwned = 9;
/// Failure to consume since item is not owned
itemNotOwned = 10;
}
If you spot any obvious error / missing code, please let me know.
.disabled
and .billingUnavailable
can probably merge. disabled
comes from the iOS part.