我相信这里的问题是您需要区分测试和生产。除非您在商店中发布,否则您无法使用生产模式。请参阅CurrentApp和CurrentAppSimulator。
从CurrentAppSimiulator
页:
备注
直到应用从Windows应用商店已经上市,CurrentApp对象将不会在应用程序工作。使用CurrentAppSimulator在开发应用程序时测试应用程序的许可和应用程序内产品。在测试应用程序之后,在将其提交到Windows应用商店之前,必须用CurrentApp替换CurrentAppSimulator的实例。如果使用CurrentAppSimulator,您的应用程序将无法通过认证。
这是我如何解决这个问题在我的应用程序与我的测试/生产改变的#define,那CurrentApp和CurrentAppSimulator之间切换,使我的其他代码的眼睛更容易的代理类。
App.xaml.cs,应用程序()
//
// configure in-app purchasing
//
#if false
#warning WARNING: You are using CurrentAppProxy in TEST MODE!
CurrentAppProxy.SetTestMode(true); // true for test, false for production
#else
CurrentAppProxy.SetTestMode(false); // true for test, false for production
CurrentAppProxy.cs
public static class CurrentAppProxy
{
static bool? testmode = null;
public static async void SetTestMode(bool mode)
{
testmode = mode;
if (mode)
{
var file = await Package.Current.InstalledLocation.GetFileAsync("WindowsStoreProxy.xml");
if (file != null)
{
await CurrentAppSimulator.ReloadSimulatorAsync(file);
}
}
}
public static LicenseInformation LicenseInformation
{
get
{
if (testmode == null) throw new NotSupportedException();
else if (testmode.Value) return CurrentAppSimulator.LicenseInformation;
else return CurrentApp.LicenseInformation;
}
}
public static IAsyncOperation<IReadOnlyList<UnfulfilledConsumable>> GetUnfulfilledConsumablesAsync()
{
if (testmode == null) throw new NotSupportedException();
else if (testmode.Value) return CurrentAppSimulator.GetUnfulfilledConsumablesAsync();
else return CurrentApp.GetUnfulfilledConsumablesAsync();
}
public static IAsyncOperation<ListingInformation> LoadListingInformationAsync()
{
if (testmode == null) throw new NotSupportedException();
else if (testmode.Value) return CurrentAppSimulator.LoadListingInformationAsync();
else return CurrentApp.LoadListingInformationAsync();
}
public static IAsyncOperation<FulfillmentResult> ReportConsumableFulfillmentAsync(string productId, Guid transactionId)
{
if (testmode == null) throw new NotSupportedException();
else if (testmode.Value) return CurrentAppSimulator.ReportConsumableFulfillmentAsync(productId, transactionId);
else return CurrentApp.ReportConsumableFulfillmentAsync(productId, transactionId);
}
public static IAsyncOperation<PurchaseResults> RequestProductPurchaseAsync(string productId)
{
if (testmode == null) throw new NotSupportedException();
else if (testmode.Value) return CurrentAppSimulator.RequestProductPurchaseAsync(productId);
else return CurrentApp.RequestProductPurchaseAsync(productId);
}
}
在我的应用程序使用...
private async Task RefreshInAppOffers()
{
// in-app offers
List<KeyValuePair<string, ProductListing>> products = null;
UnfulfilledConsumable unfulfilledConsumable = null;
InAppOffers.Children.Clear();
try
{
var listinginfo = await CurrentAppProxy.LoadListingInformationAsync();
products = listinginfo.ProductListings.ToList();
products.Sort((p1, p2) => p1.Value.FormattedPrice.CompareTo(p2.Value.FormattedPrice));
CurrentAppProxy是他们在这里的关键。如果它适用于模拟器,它应该适用于您的生产项目。你只需要为所有各种条件准备好所有其他部分。一些测试在调试器中最容易实现。
我有一个消耗品显示为IAPs溢价和标签是溢价和我使用的密钥也溢价。所以可能会使用点和其他符号在某个地方有一个错误,谁知道 –
@JuanPabloGarciaCoello如果我只能在将应用程序提交到商店之前进行可靠的测试,那么我相信商店会修改软件包以包含应用程序内购买信息 – JBernardo
在我的案例中,此消息'选择另一个项目'在IAP项目认证后的几天内显示。但后来,错误消息已经消失。 – pnp0a03