Windows Phone 应用内商品 ListingInformation.ProductListings 不包含所有商品
Windows Phone in-app products ListingInformation.ProductListings does not contain all products
我有 Windows phone 8.0 c# 应用程序。有很多与此应用程序相关的应用程序内耐用产品(大约 2000 个)。该应用程序已发布,并且可以在应用程序商店中购买与该应用程序关联的任何耐用产品。它工作正常。
我想刷新应用程序中的所有产品价格并显示实际价格列表(从应用商店加载)。
我使用这个代码:
var asyncListingInformation = CurrentApp.LoadListingInformationAsync();
asyncListingInformation.Completed = (async, status) =>
{
try
{
var listingInformation = async.GetResults();
int count = 0; // Compute count of returned products
foreach (var pair in listingInformation.ProductListings)
{
string productId = pair.Value.ProductId;
string price = pair.Value.FormattedPrice;
this.UpdateProductPrice(productId, price);
count++;
}
Debug.WriteLine(count); // Returns: 100
}
catch (Exception e)
{
}
};
问题是 listingInformation.ProductListings 只包含 100 个产品,但服务器上有更多的产品。
我无法检索超过 100 个产品的问题出在哪里?有没有其他方法如何从应用商店加载指定产品的价格?应用程序知道所有产品 ID。
尝试使用CurrentApp.LoadListingInformationByProductIdsAsync方法。
您的代码应该更改:
List<string> productIds = new List<string>();
foreach (var product in myProducts) // << Change myProducts and set your collection of products. myProducts contains for example 2000 items.
{
productIds.Add(product.ProductId);
}
var asyncListingInformation = CurrentApp.LoadListingInformationByProductIdsAsync(productIds);
asyncListingInformation.Completed = (async, status) =>
{
try
{
var listingInformation = async.GetResults();
int count = 0; // Compute count of returned products
foreach (var pair in listingInformation.ProductListings)
{
string productId = pair.Value.ProductId;
string price = pair.Value.FormattedPrice;
this.UpdateProductPrice(productId, price);
count++;
}
Debug.WriteLine(count); // Returns: 2000 :-)
}
catch (Exception e)
{
}
};
我有 Windows phone 8.0 c# 应用程序。有很多与此应用程序相关的应用程序内耐用产品(大约 2000 个)。该应用程序已发布,并且可以在应用程序商店中购买与该应用程序关联的任何耐用产品。它工作正常。
我想刷新应用程序中的所有产品价格并显示实际价格列表(从应用商店加载)。
我使用这个代码:
var asyncListingInformation = CurrentApp.LoadListingInformationAsync();
asyncListingInformation.Completed = (async, status) =>
{
try
{
var listingInformation = async.GetResults();
int count = 0; // Compute count of returned products
foreach (var pair in listingInformation.ProductListings)
{
string productId = pair.Value.ProductId;
string price = pair.Value.FormattedPrice;
this.UpdateProductPrice(productId, price);
count++;
}
Debug.WriteLine(count); // Returns: 100
}
catch (Exception e)
{
}
};
问题是 listingInformation.ProductListings 只包含 100 个产品,但服务器上有更多的产品。 我无法检索超过 100 个产品的问题出在哪里?有没有其他方法如何从应用商店加载指定产品的价格?应用程序知道所有产品 ID。
尝试使用CurrentApp.LoadListingInformationByProductIdsAsync方法。 您的代码应该更改:
List<string> productIds = new List<string>();
foreach (var product in myProducts) // << Change myProducts and set your collection of products. myProducts contains for example 2000 items.
{
productIds.Add(product.ProductId);
}
var asyncListingInformation = CurrentApp.LoadListingInformationByProductIdsAsync(productIds);
asyncListingInformation.Completed = (async, status) =>
{
try
{
var listingInformation = async.GetResults();
int count = 0; // Compute count of returned products
foreach (var pair in listingInformation.ProductListings)
{
string productId = pair.Value.ProductId;
string price = pair.Value.FormattedPrice;
this.UpdateProductPrice(productId, price);
count++;
}
Debug.WriteLine(count); // Returns: 2000 :-)
}
catch (Exception e)
{
}
};