コード例 #1
0
        private async Task RemoveAdsAsync()
        {
            if (IsBusy)
            {
                return;
            }

            try
            {
                IsBusy = true;
                var productID = Options.GetInAppPurchaseProductID();
                var status    = await _inAppPurchaseService.CheckAppPurchaseStatus(productID);

                if (AreAdsRemoved(status))
                {
                    PurchaseStatus = (int)status;
                    SetRemoveAdsText(true);
                    return;
                }

                var purchaseResult = await _inAppPurchaseService.MakePurchaseAsync(productID);

                if (AreAdsRemoved(purchaseResult))
                {
                    PurchaseStatus = (int)purchaseResult;
                    SetRemoveAdsText(true);
                }
                else
                {
                    SetRemoveAdsText(false);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                IsBusy = false;
            }
        }