Esempio n. 1
0
        private async void WatchAnAd()
        {
            if (!InternetConnectivityHelper.IsInternetConnected)
            {
                await NotifyAndDeselect("Seems you don't have an internet connection. Thanks for the support, though!");

                return;
            }
            StoreServicesCustomEventLogger logger = StoreServicesCustomEventLogger.GetDefault();

            InterstitialAd ad         = new InterstitialAd();
            string         myAppId    = "9nblggh42srx";
            string         myAdUnitId = "11701839";

            ad.Keywords = "music,software,apps";
            ad.AdReady += async(r, a) =>
            {
                if (InterstitialAdState.Ready == ad.State)
                {
                    logger.Log("WatchAnAdStarted");
                    ad.Show();
                    await SharedLogic.Instance.NotificationManager.ShowMessageBoxAsync("Please click at least one link to help me more! Thanks!", "Thank you so much!");
                }
            };
            ad.Completed += async(r, a) =>
            {
                logger.Log("WatchAnAdCompleted");
                await NotifyAndDeselect("Thanks!");
            };
            ad.Cancelled += async(r, a) =>
            {
                await NotifyAndDeselect("No worries!");
            };
            int retryCount = 0;

            ad.ErrorOccurred += async(r, a) =>
            {
                if (retryCount < 2)
                {
                    retryCount++;
                    await NotifyAndDeselect("Aw! An error occured. Trying something else. Please wait.");

                    myAdUnitId = "1100000276";
                    ad.RequestAd(AdType.Display, myAppId, myAdUnitId);
                }
                else
                {
                    await NotifyAndDeselect("Aw! An error occured. Thanks anyway.");
                }
            };
            ad.RequestAd(AdType.Video, myAppId, myAdUnitId);
            await NotifyAndDeselect("Please continue. The ad will be shown shortly.");

            async Task NotifyAndDeselect(string message)
            {
                await SharedLogic.Instance.NotificationManager.ShowMessageAsync(message);

                SplitViewMenu.SelectPrevious();
            }
        }
Esempio n. 2
0
        public async void ConsumeAddOn(string storeId)
        {
            if (context == null)
            {
                context = StoreContext.GetDefault();
                // If your app is a desktop app that uses the Desktop Bridge, you
                // may need additional code to configure the StoreContext object.
                // For more info, see https://aka.ms/storecontext-for-desktop.
            }
            Guid trackingId = Guid.NewGuid();

            StoreConsumableResult result = await context.ReportConsumableFulfillmentAsync(
                storeId, 1, trackingId);

            // Capture the error message for the operation, if any.
            string extendedError = string.Empty;

            if (result.ExtendedError != null)
            {
                extendedError = result.ExtendedError.Message;
            }

            switch (result.Status)
            {
            case StoreConsumableStatus.Succeeded:
                await SharedLogic.Instance.NotificationManager.ShowMessageAsync("Purchase fullfilled successfully.");

                this.Hide();
                SplitViewMenu.SelectPrevious();
                break;

            case StoreConsumableStatus.NetworkError:
                await SharedLogic.Instance.NotificationManager.ShowMessageAsync("The fulfillment was unsuccessful due to a network error. " +
                                                                                "ExtendedError: " + extendedError);

                break;

            case StoreConsumableStatus.ServerError:
                await SharedLogic.Instance.NotificationManager.ShowMessageAsync("The fulfillment was unsuccessful due to a server error. " +
                                                                                "ExtendedError: " + extendedError);

                break;

            default:
                await SharedLogic.Instance.NotificationManager.ShowMessageAsync("The fulfillment was unsuccessful due to an unknown error. " +
                                                                                "ExtendedError: " + extendedError);

                break;
            }
        }
Esempio n. 3
0
        public async void PurchaseAddOn(string addOnStoreId)
        {
            if (context == null)
            {
                context = StoreContext.GetDefault();
            }

            StorePurchaseResult result = await context.RequestPurchaseAsync(addOnStoreId);

            // Capture the error message for the operation, if any.
            string extendedError = string.Empty;

            if (result.ExtendedError != null)
            {
                extendedError = result.ExtendedError.Message;
            }

            switch (result.Status)
            {
            case StorePurchaseStatus.Succeeded:
                await SharedLogic.Instance.NotificationManager.ShowMessageAsync("Thanks for the donation! Love you!");

                ConsumeAddOn(addOnStoreId);
                this.Hide();
                SplitViewMenu.SelectPrevious();
                break;

            case StorePurchaseStatus.NetworkError:
                await SharedLogic.Instance.NotificationManager.ShowMessageAsync("The purchase was unsuccessful due to a network error. " +
                                                                                "ExtendedError: " + extendedError);

                break;

            case StorePurchaseStatus.ServerError:
                await SharedLogic.Instance.NotificationManager.ShowMessageAsync("The purchase was unsuccessful due to a server error. " +
                                                                                "ExtendedError: " + extendedError);

                break;

            default:
                await SharedLogic.Instance.NotificationManager.ShowMessageAsync("The purchase was unsuccessful due to an unknown error. " +
                                                                                "ExtendedError: " + extendedError);

                break;
            }
        }
Esempio n. 4
0
 private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
 {
     this.Hide();
     SplitViewMenu.SelectPrevious();
 }