Core refactoring (app doesn't work)
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using Microsoft.Advertising.WinRT.UI;
|
||||
using Microsoft.AppCenter.Crashes;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Services.Store;
|
||||
|
||||
namespace FoxTube.Utils
|
||||
{
|
||||
public static class StoreInterop
|
||||
{
|
||||
public static bool AdsDisabled { get; private set; } = true;
|
||||
public static string Price { get; private set; }
|
||||
|
||||
|
||||
private static bool UseTestAds => true;
|
||||
|
||||
private static string ApplicationId => UseTestAds ? "d25517cb-12d4-4699-8bdc-52040c712cab" : "9ncqqxjtdlfh";
|
||||
private static string AdsId => UseTestAds ? "test" : "1100044398";
|
||||
private static string ProProductId => "9NP1QK556625";
|
||||
|
||||
public static NativeAdsManagerV2 AdsManager => new NativeAdsManagerV2(ApplicationId, AdsId);
|
||||
|
||||
public static async Task 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;
|
||||
}
|
||||
}
|
||||
|
||||
public static async void RequestReview()
|
||||
{
|
||||
StoreRateAndReviewResult result = await StoreContext.GetDefault().RequestRateAndReviewAppAsync();
|
||||
|
||||
if (result.Status == StoreRateAndReviewStatus.Error)
|
||||
Metrics.SendReport(result.ExtendedError, new[] { ErrorAttachmentLog.AttachmentWithText(result.ExtendedJsonData, "extendedJsonData.json") },
|
||||
("Status", result.Status.ToString()),
|
||||
("WasReviewUpdated", result.WasUpdated.ToString()));
|
||||
|
||||
Metrics.AddEvent("Store review request has been recieved");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user