【问题标题】:in app purchase issue in windows store appWindows 商店应用中的应用内购买问题
【发布时间】:2016-03-09 02:35:21
【问题描述】:

我创建了一个应用程序内购买的应用程序并使用CurrentAppSimulator 对其进行了测试,并且工作正常,但是当我为应用程序创建包时它失败了

这是我正在为其创建包的代码

public async System.Threading.Tasks.Task InAppInit()
{

    var listing = await CurrentApp.LoadListingInformationAsync();

    // Delux Unlock - Durable
    var unlockFeatureDelux = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == "deluxe" && p.Value.ProductType == ProductType.Durable);
    isDeluxPurchased = CurrentApp.LicenseInformation.ProductLicenses[unlockFeatureDelux.Value.ProductId].IsActive;
    deluxProductID = unlockFeatureDelux.Value.ProductId;

    // Standard Unlock - Durable
    var unlockFeatureStandard = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == "standard" && p.Value.ProductType == ProductType.Durable);
    isStarndardPurchased = CurrentApp.LicenseInformation.ProductLicenses[unlockFeatureStandard.Value.ProductId].IsActive;
    standardProductID = unlockFeatureStandard.Value.ProductId;

}

我在App.xaml.cs中调用这个方法OnLaunched

【问题讨论】:

  • 失败怎么办?错误?结果无效?
  • 据我所知,与 Store 合作很糟糕 :) 它经常失败。首先,您可以将代码包装在 try\catch
  • 愿意分享一下这个例外是什么?..
  • 实际上在商店应用程序中,您创建了一个应该通过不同测试的包,而我的应用程序在“onapplaunch”测试中失败。
  • 它没有获得应用内购买 ID

标签: c# windows windows-runtime windows-phone-8.1 windows-store-apps


【解决方案1】:

根据我们的讨论,我会这样做:

  • LoadListingInformationAsync 方法使用互联网,如果用户没有互联网连接,则会抛出异常。所以我建议把这些东西包装到一个 try/ctach 块中
  • 正如我们所见,ProductListings 不包含任何项目。我不知道这个列表是如何填充的,但是只要您的应用程序不在商店中,当该列表为空时我不会感到惊讶(也许有人可以在这里提供帮助......但我没有找到任何关于这个在文档中)。因此,为此,我只需检查您需要的功能是否在列表中...有了这个,您的包将通过您提到的测试,您可以上传它。如果通过商店安装软件包时列表也是空的,那么 IAP 设置有问题(但这与商店有关..)
  • 一般性评论:显然这段代码不完整......您需要一些代码来购买 IAP,而这里我们只获取 ID。(但我认为您只是粘贴了相关部分。)

所有这些都在代码中:

 public async System.Threading.Tasks.Task InAppInit()
    {
        try
        {
            var listing = await CurrentApp.LoadListingInformationAsync();
            if (listing.ProductListings.ContainsKey("deluxe"))
            {
                // Delux Unlock - Durable
                var unlockFeatureDelux = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == "deluxe" && p.Value.ProductType == ProductType.Durable);
                isDeluxPurchased = CurrentApp.LicenseInformation.ProductLicenses[unlockFeatureDelux.Value.ProductId].IsActive;
                deluxProductID = unlockFeatureDelux.Value.ProductId;
            }
            else
            {
                //There is no deluxe IAP defined... so something with your IAP stuff is wrong...
            }

            if (listing.ProductListings.ContainsKey("standard"))
            {
                // Standard Unlock - Durable
                var unlockFeatureStandard = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == "standard" && p.Value.ProductType == ProductType.Durable);
                isStarndardPurchased = CurrentApp.LicenseInformation.ProductLicenses[unlockFeatureStandard.Value.ProductId].IsActive;
                standardProductID = unlockFeatureStandard.Value.ProductId;
            }
            else
            {
                //same as for Delux
            }
        }
        catch
        {
            //Show  this on the UI...
        }
    }

【讨论】:

  • 感谢您的帮助,它解决了我的问题,现在我将通过测试版检查它是否有效
  • 我认为它应该与商店相关。下一步是再次查看商店中的 IAP 设置。由于某种原因,该应用似乎没有获得 IAP 列表...您应该弄清楚原因
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-27
相关资源
最近更新 更多