android - Xamarin.InAppBilling (2.2.0) 调用了 Android BuyProduct() 但有时未调用回调 - 如何诊断/修复根本原因?

标签 android xamarin xamarin.android in-app-purchase google-play-services

过去几周,我们在 Android 上遇到了一些失败的应用内购买失败(iOS 一直很好)。

我们使用的 Xamarin.InAppBilling 组件(版本 2.2.0)已经好几个月了,但最近我们可以看到我们正在调用行 (A) 但没有调用通常的 IAP 回调,这意味着...

  • Google 没有收到购买请求 - 我们可以排除这种情况,他们正在收费。

  • Google 不回复 - 我们最有可能的情况

  • Xamarin.InAppBilling 中的错误 - 不太可能,因为它迄今为止一直有效。

  • 我们没有正确注册回调 - 不太可能,因为我们已经在每个回调的第一行记录...

        _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;
    

这是调用购买的代码的摘录...

        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");

大多数时候会调用 BillingHandler 回调,但当它不起作用时,似乎没有调用这些回调。

我们已经在 Android 7 和 8 上看到过这种情况(因此这是一个 Android 8 问题)。

我们不确定从这里到哪里去,欢迎任何关于进一步调试的建议。

最佳答案

好的,

事实证明这是 Google 的一个问题

Thanks for your reply to Google Play Developer Support!

Our team have recently made some changes that should fix this issue (which is what you have confirmed).

On the other hand, we do encourage developers to use our new Play Billing library (https://developer.android.com/google/play/billing/billing_library.html), which gracefully handles most of use cases, and a good example of integrating with it is our open-sourced sample: https://github.com/googlesamples/android-play-billing/tree/master/TrivialDrive_v2 I appreciate your patience on this fix, I hope this helps! If you have any further questions, please let me know. I'm happy to help.

关于android - Xamarin.InAppBilling (2.2.0) 调用了 Android BuyProduct() 但有时未调用回调 - 如何诊断/修复根本原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46258255/

相关文章:

android - 当他进入android中的电影院时如何通知用户?

java - android 使用 parse.com api 通过推送通知实现聊天

xaml - 为什么我的 Xamarin.Forms 中的选择器没有显示

android - native Facebook 登录到 Xamarin WebApp

c# - 文件 "obj\Debug\android\bin\packaged_resources"不存在。在 Windows 8.1 上的 Visual Studio 2015 Xamarin 跨平台中

android-layout - 使用 Xamarin 在 Visual Studio 中编辑 android 布局时自动完成

java - Android Paint breakText 换行

Android Studio 版本控制不断将构建目录添加到提交中

c# - 如何在 Windows Phone 8 中导航页面

c# - 单体机器人 : Performing a full GC