我开发了一个包含 IAP 的免费 UWP 应用。
我为 Windows 10 Mobile 开发了这个应用程序。我向名为customBackground的商店发布了一个 IAP ,并将我的应用程序和 IAP 发布到了商店。
在他们两个都发布后,我从商店下载了我发布的应用程序并尝试购买 IAP。
但是,它返回了一个系统弹出窗口,上面写着“此应用内项目在 MY-APP-NAME 中不再可用”。我不知道为什么会这样。
有问题:
当我在 Visual Studio 中使用CurrentAppSimulator类尝试调试模式时,它不会在我的手机或模拟器上弹出购买状态选择,但会在桌面版本上弹出。它只读取 WindowsStoreProxy.xml 中存储的状态。
IAP 发布后,我还尝试在调试/发布模式下使用CurrentApp类,但没有运气,它返回与商店版本相同的错误。
Package.appxmanifest 中的 Internet 权限已启用。
这是我在商店中发布的应用程序中的代码:
private async void buy_Click(object sender, RoutedEventArgs e)
{
LicenseInformation licenseInformation = CurrentApp.LicenseInformation;
if (!licenseInformation.ProductLicenses["customBackground"].IsActive)
{
Debug.WriteLine("Buying this feature...");
try
{
await CurrentApp.RequestProductPurchaseAsync("customBackground");
if (licenseInformation.ProductLicenses["customBackground"].IsActive)
{
var purchaseStat = LocalizedStrings.GetString(LocalizedStringEnum.havePurchased);
var b = new MessageDialog(purchaseStat);
b.ShowAsync();
Debug.WriteLine("You bought this feature.");
isIAPValid = true;
}
else
{
var purchaseStat = LocalizedStrings.GetString(LocalizedStringEnum.notPurchased);
var b = new MessageDialog(purchaseStat);
b.ShowAsync();
Debug.WriteLine("this feature was not purchased.");
}
}
catch (Exception)
{
var purchaseStat = LocalizedStrings.GetString(LocalizedStringEnum.purchaseFailed);
var b = new MessageDialog(purchaseStat);
b.ShowAsync();
Debug.WriteLine("Unable to buy this feature.");
}
}
else
{
var purchaseStat = LocalizedStrings.GetString(LocalizedStringEnum.alreadyOwned);
var b = new MessageDialog(purchaseStat);
b.ShowAsync();
Debug.WriteLine("You already own this feature.");
isIAPValid = true;
}
}
谢谢!