Google是否会缓存为离线参考而购买的产品?

时间:2018-01-11 05:25:41

标签: android xamarin google-play in-app-billing

在卸载/重新安装,清除应用数据以及设备离线时,计费服务如何验证旧购买时感到困惑。我正在使用James Montemagno的Plugin.InAppBilling for Xamarin。我有一个非常简单的MyProduct类与此函数。

当设备离线时,从GetPurchasesAsync返回的IEnumerable在其中进行了测试购买。这些信息是否存储在Google Play服务中?我该如何摆脱它?

public async Task<bool> WasItemPurchased()
        {

            var billing = CrossInAppBilling.Current;
            try
            {
                var connected = await billing.ConnectAsync();

                if (!connected)
                {
                    //Couldn't connect
                    this.PurchYN = false;
                }

                //check purchases
                var purchases = await billing.GetPurchasesAsync(ItemType.InAppPurchase);

                //check for null just incase
                if (purchases?.Any(p => p.ProductId == this.AppProdID) ?? false)
                {
                    //Purchase restored
                    this.PurchYN = true;
                }
                else
                {
                    //no purchases found
                    this.PurchYN = false;
                }
            }
            catch (InAppBillingPurchaseException purchaseEx)
            {
                //Billing Exception handle this based on the type
                Debug.WriteLine("Error: " + purchaseEx);
            }
            catch (Exception ex)
            {
                this.PurchYN = false;
            }
            finally
            {
                await billing.DisconnectAsync();
            }

            return this.PurchYN;
        }

1 个答案:

答案 0 :(得分:0)

如果您清除Play商店的缓存数据,则应将其删除。