Updated StoreInterop class and ads appearing conditions
This commit is contained in:
@@ -1,24 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Services.Store;
|
||||
|
||||
namespace FoxTube.Core.Controllers
|
||||
{
|
||||
public static class StoreInterop
|
||||
{
|
||||
public static bool AdsDisabled => false;
|
||||
public static string GetProPrice()
|
||||
public static bool AdsDisabled { get; private set; } = true;
|
||||
public static string Price { get; private set; }
|
||||
|
||||
public static async Task UpdateStoreState()
|
||||
{
|
||||
return "$4.99";
|
||||
StoreProductQueryResult requset = await StoreContext.GetDefault().GetAssociatedStoreProductsAsync(new[] { "Durable" });
|
||||
|
||||
if (requset.Products["9NP1QK556625"].IsInUserCollection)
|
||||
return;
|
||||
|
||||
Price = requset.Products["9NP1QK556625"].Price.FormattedPrice;
|
||||
AdsDisabled = false;
|
||||
}
|
||||
|
||||
public static void PurchaseApp()
|
||||
public static async Task<bool> PurchaseApp()
|
||||
{
|
||||
if (!AdsDisabled)
|
||||
// TODO: Add purchase validation
|
||||
return;
|
||||
StorePurchaseResult request = await StoreContext.GetDefault().RequestPurchaseAsync("9NP1QK556625");
|
||||
|
||||
switch (request.Status)
|
||||
{
|
||||
case StorePurchaseStatus.AlreadyPurchased:
|
||||
case StorePurchaseStatus.Succeeded:
|
||||
AdsDisabled = true;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="Controllers\StoreInterop.cs" />
|
||||
<Compile Include="Helpers.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -130,6 +131,9 @@
|
||||
<Version>6.2.9</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FoxTube.Core
|
||||
{
|
||||
public static class Helpers
|
||||
{
|
||||
public static Uri ToUri(this string str) =>
|
||||
string.IsNullOrWhiteSpace(str) ? null : new Uri(str);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user