Archived
1
0
This repository has been archived on 2026-04-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Michael Gordeev 787a6e9f48 Refactored core
UI navigation framework

Related Work Items: #408, #414, #416
2020-06-15 15:46:38 +03:00

48 lines
1.4 KiB
C#

using Microsoft.Advertising.WinRT.UI;
using System;
using System.Threading.Tasks;
using Windows.Services.Store;
namespace FoxTube.Utils
{
public static class AddonsInterop
{
public static bool AdsDisabled { get; private set; } = true;
public static string Price { get; private set; }
private const bool UseTestAds = true;
public static string ApplicationId => UseTestAds ? "d25517cb-12d4-4699-8bdc-52040c712cab" : SecretConstants.ApplicationProductId;
public static string AdsId => UseTestAds ? "test" : SecretConstants.AdsUnitId;
private const string ProProductId = SecretConstants.ProAddonId;
public static NativeAdsManagerV2 AdsManager => new NativeAdsManagerV2(ApplicationId, AdsId);
public static async Task<bool> UpdateProPurchasedState()
{
StoreProductQueryResult requset = await StoreContext.GetDefault().GetAssociatedStoreProductsAsync(new[] { "Durable" });
if (requset.Products[ProProductId].IsInUserCollection)
return AdsDisabled = true;
Price = requset.Products[ProProductId].Price.FormattedPrice;
return AdsDisabled = false;
}
public static async Task<bool> PurchaseApp()
{
StorePurchaseResult request = await StoreContext.GetDefault().RequestPurchaseAsync(ProProductId);
switch (request.Status)
{
case StorePurchaseStatus.AlreadyPurchased:
case StorePurchaseStatus.Succeeded:
AdsDisabled = true;
return true;
default:
return false;
}
}
}
}