Archived
1
0

Core update. Base core features are done (main app doesn't compile)

Related Work Items: #416, #422, #423, #424
This commit is contained in:
Michael Gordeev
2020-06-11 21:17:18 +03:00
parent b3212738e8
commit c58d846057
18 changed files with 386 additions and 281 deletions
+50
View File
@@ -0,0 +1,50 @@
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);
static AddonsInterop() =>
UpdateStoreState();
public static async void UpdateStoreState()
{
StoreProductQueryResult requset = await StoreContext.GetDefault().GetAssociatedStoreProductsAsync(new[] { "Durable" });
if (requset.Products[ProProductId].IsInUserCollection)
return;
Price = requset.Products[ProProductId].Price.FormattedPrice;
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;
}
}
}
}