Core update. Base core features are done (main app doesn't compile)
Related Work Items: #416, #422, #423, #424
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user