Пример #1
0
 private static void OnLicenseChanged()
 {
     if (LicenseChangedEvent != null)
     {
         EtceteraWindows.RunOnUnityThread(LicenseChangedEvent);
     }
 }
Пример #2
0
        private static async void Purchase(string productId, Action <PurchaseResults, Exception> completionHandler)
        {
            Exception exception = null;
            string    result    = null;

            try
            {
                result = await CurrentApp.RequestProductPurchaseAsync(productId, true);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            if (completionHandler != null)
            {
                PurchaseResults purchase = null;
                if (result != null)
                {
                    purchase = new PurchaseResults();
                    //purchase.offerId = result.OfferId;
                    purchase.Status     = ProductPurchaseStatus.Succeeded;
                    purchase.ReceiptXml = result;
                    //purchase.transactionId = result.TransactionId;
                }

                EtceteraWindows.RunOnUnityThread(() => completionHandler(purchase, exception));
            }
        }
Пример #3
0
 /// <summary>
 /// Shows an interstitial as long as one is loaded
 /// </summary>
 public static void ShowInterstitial()
 {
     EtceteraWindows.RunOnUIThread(() =>
     {
         if (interstitialAd != null)
         {
             interstitialAd.ShowAd();
         }
     });
 }
Пример #4
0
 public static void ShowVideo()
 {
     EtceteraWindows.RunOnUIThread(() =>
     {
         if (videoAd != null)
         {
             videoAd.ShowAd();
         }
     });
 }
Пример #5
0
        private static async void LoadListing(Action <ListingInformation, Exception> onComplete)
        {
            try
            {
#if DEBUG
                var task = CurrentApp.LoadListingInformationAsync();
#else
                var task = CurrentApp.LoadListingInformationAsync().AsTask();
#endif
                await task;

                var information = task.Result;

                if (information != null)
                {
                    var listing = new ListingInformation();
                    listing.AgeRating       = information.AgeRating;
                    listing.CurrentMarket   = information.CurrentMarket;
                    listing.Description     = information.Description;
                    listing.FormattedPrice  = information.FormattedPrice;
                    listing.Name            = information.Name;
                    listing.ProductListings = new Dictionary <string, ProductListing>();
                    var productListings = information.ProductListings;

                    foreach (var productListing in productListings)
                    {
                        var value   = productListing.Value;
                        var product = new ProductListing();
                        product.ProductId      = value.ProductId;
                        product.ProductType    = (ProductType)value.ProductType;
                        product.FormattedPrice = value.FormattedPrice;
                        product.Name           = value.Name;
                        listing.ProductListings.Add(productListing.Key, product);
                    }
                    if (onComplete != null)
                    {
                        EtceteraWindows.RunOnUnityThread(() => onComplete(listing, null));
                    }
                }
                else
                {
                    if (onComplete != null)
                    {
                        EtceteraWindows.RunOnUnityThread(() => onComplete(null, new Exception("ListingInformation is null")));
                    }
                }
            }
            catch (Exception ex)
            {
                if (onComplete != null)
                {
                    EtceteraWindows.RunOnUnityThread(() => onComplete(null, ex));
                }
            }
        }
Пример #6
0
        private static async void LoadProductReceipts(List <string> productIds, Action <List <ProductReceipt>, Exception> onComplete)
        {
            var receipts = new List <ProductReceipt>();

            for (int index = 0; index < productIds.Count; index++)
            {
                var productId = productIds[index];

                if (string.IsNullOrEmpty(productId))
                {
                    continue;
                }

                try
                {
#if DEBUG
                    var task = CurrentApp.GetProductReceiptAsync(productId);
#else
                    var task = CurrentApp.GetProductReceiptAsync(productId).AsTask();
#endif
                    await task;

                    var receiptXml = task.Result;

                    var receipt = ProductReceipt.CreateReceipt(receiptXml);

                    receipts.Add(receipt);
                }
                catch (Exception ex)
                {
                    if (onComplete != null)
                    {
                        EtceteraWindows.RunOnUnityThread(() => onComplete(null, ex));
                    }
                    return;
                }
            }

            if (onComplete != null)
            {
                EtceteraWindows.RunOnUnityThread(() => onComplete(receipts, null));
            }
        }
Пример #7
0
        /// <summary>
        /// Reports a consumable as fullfilled. You should call this once you have granted the consumable to the player.
        ///
        /// </summary>
        /// <param name="productId"/><param name="transactionId"/><param name="completionHandler"/>

        public static void ReportConsumableFulfillment(string productId, Guid transactionId, Action <FulfillmentResult, Exception> onComplete)
        {
            Exception exception = null;

            try
            {
                CurrentApp.ReportProductFulfillment(productId);
                if (onComplete != null)
                {
                    EtceteraWindows.RunOnUnityThread(() => onComplete(FulfillmentResult.Succeeded, null));
                }
            }
            catch (Exception ex)
            {
                if (onComplete != null)
                {
                    EtceteraWindows.RunOnUnityThread(() => onComplete(FulfillmentResult.ServerError, ex));
                }
            }
        }
Пример #8
0
 /// <summary>
 /// Requests a purchase of the application. completionHandler gets called with either true or false indicating if
 ///             the app was purchased.
 ///
 /// </summary>
 public static async void RequestProductPurchase(string productId, Action <PurchaseResults, Exception> onComplete)
 {
     EtceteraWindows.RunOnUIThread(() => Purchase(productId, onComplete));
 }
Пример #9
0
 /// <summary>
 /// Loads listing information and fires completingHandler with the data once loading completes
 ///
 /// </summary>
 /// <param name="completionHandler"/>
 public static void LoadListingInformation(Action <ListingInformation, Exception> onComplete)
 {
     EtceteraWindows.RunOnUIThread(() => LoadListing(onComplete));
 }
Пример #10
0
 /// <summary>
 /// Gets the product receipt for the given productId.
 ///
 /// </summary>
 /// <param name="productId"/>
 /// <returns/>
 public static async void GetProductReceipts(List <string> productIds, Action <List <ProductReceipt>, Exception> onComplete)
 {
     EtceteraWindows.RunOnUIThread(() => LoadProductReceipts(productIds, onComplete));
 }