private async Task <bool> CheckPurchase()
        {
            try
            {
                if (_billingHelper == null)
                {
                    Toast.MakeText(this, "عدم اتصال به کافه بازار و یا مایکت لطفا برنامه را مجددا اجرا کنید", ToastLength.Long);
                    return(false);
                }

                var products = await _billingHelper.QueryInventoryAsync(new List <string>() { Billing.Billing.Sku }, ItemType.Subscription);

                if (products == null || !products.Any())
                {
                    Toast.MakeText(this, "لطفا در اپلیکیشن کافه بازار و یا مایکت وارد اکانت شوید ", ToastLength.Long);
                    return(false);
                }

                var isPurchase = _billingHelper.GetPurchases(ItemType.InApp);
                if (isPurchase != null && isPurchase.Any(en => en.ProductId == products.FirstOrDefault().ProductId))
                {
                    return(true);
                }

                _billingHelper.LaunchPurchaseFlow(Billing.Billing.Sku, ItemType.Subscription, "");
                return(false);
            }
            catch (Exception er)
            {
                var msg = er.Message;
                return(false);
            }
        }
        private void BtnConsumePurchase_Click(object sender, EventArgs e)
        {
            try
            {
                var  purchases     = _billingHelper.GetPurchases("inapp");
                var  purchasedItem = purchases.First();
                bool result        = _billingHelper.ConsumePurchase(purchasedItem);

                if (result)
                {
                    _purchasesAdapter.Items.Remove(purchasedItem);
                    _purchasesAdapter.NotifyDataSetChanged();
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 3
0
        public bool AdsEnabled()
        {
            if (_billingHelper == null)
            {
                return(true);
            }

            var purchases = _billingHelper.GetPurchases(ItemType.InApp);

            return(purchases.Count <= 0);
        }