Over the past couple of weeks, we have encountered a number of unsuccessful crashes when purchasing applications on Android (iOS was fine).
We use the Xamarin.InAppBilling component (version 2.2.0), which has been absolutely perfect for many months, but recently we see that we call line (A), but normal IAP calls are not called, which implies ...
Google does not receive a purchase request - we can exclude this, they are charging.
Google doesn't answer - our most likely scenario
The error in Xamarin.InAppBilling is unlikely, as it works to date.
We did not register the callback correctly - it is unlikely because we have an entry in the first line of each callback ...
_serviceConnection.BillingHandler.OnUserCanceled += BillingHandler_OnProductCanceled; _serviceConnection.BillingHandler.OnProductPurchased += BillingHandler_OnProductPurchased; _serviceConnection.BillingHandler.OnGetProductsError += BillingHandler_OnGetProductsError; _serviceConnection.BillingHandler.OnPurchaseConsumed += BillingHandler_OnPurchaseConsumed; _serviceConnection.BillingHandler.OnPurchaseConsumedError += BillingHandler_OnPurchaseConsumedError; _serviceConnection.BillingHandler.OnProductPurchasedError += BillingHandler_OnProductPurchasedError; _serviceConnection.BillingHandler.OnPurchaseFailedValidation += BillingHandler_OnPurchaseFailedValidation; _serviceConnection.BillingHandler.OnInvalidOwnedItemsBundleReturned += BillingHandler_OnInvalidOwnedItemsBundleReturned;
Here is an excerpt of the code that causes the purchase ...
Device.BeginInvokeOnMainThread (async () => { var products = await _serviceConnection.BillingHandler.QueryInventoryAsync (new List<String> { consumableSku }, ItemType.Product); if (products != null && products.Count == 1) { var product = products [0]; logger.Log ("FeatureService purchaseConsumableFromGooglePlay product:"+product.ToString()+ " payload:" + this.developerPayload); // (A) _serviceConnection.BillingHandler.BuyProduct (product, this.developerPayload); } else { this.iapConsumableEvent.Purchased = false; this.Publish<IapConsumableEvent> (this.iapConsumableEvent); } }); logger.Log ("FeatureService purchaseConsumableFromGooglePlay completed");
In most cases, the BillingHandler callback is called, but when it does not work, it seems that these callbacks are not being called.
We saw this on Android 7 and 8 (so this is a problem with Android 8).
We are not sure where to go from here, any suggestions for debugging this are appreciated.
android google-play-services xamarin xamarin.android in-app-purchase
Devology Ltd
source share