787a6e9f48
UI navigation framework Related Work Items: #408, #414, #416
48 lines
1.4 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|