【问题标题】:Windows Phone in-app products ListingInformation.ProductListings does not contain all productsWindows Phone 应用内产品 ListingInformation.ProductListings 不包含所有产品
【发布时间】:2015-02-01 05:56:02
【问题描述】:

我有 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。

【问题讨论】:

    标签: c# windows-phone-8


    【解决方案1】:

    尝试使用 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)
        {
        }
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-09
      • 2019-04-22
      • 2018-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多