【问题标题】:windows phone 8.1 inapp purchasewindows phone 8.1 内购
【发布时间】:2014-11-10 01:14:29
【问题描述】:

我为 Windows 8.1 开发了一个 Windows 通用应用程序。此应用在 Windows 应用商店中按预期运行(包括在应用内购买)

不过,我在 Windows Phone Store 上遇到了一些问题。在设备上(运行 Windows Phone 8.1)此消息:无法在目录中找到项目;我们查看但找不到您想购买的商品。,在尝试应用内购买时显示。

 public sealed partial class MainPage : Page
{
    public event EventHandler<MainPageSizeChangedEventArgs> MainPageResized;

    private String ProductId = "focusmedica.ud.cabg";
    private String[] video = {  "Video1",
                                "Video2",
                                "Video3",
                                "Video4",
                                "Video5"

                             };

    LicenseChangedEventHandler licenseChangeHandler = null;

    public MainPage()
    {
        this.InitializeComponent();
        this.NavigationCacheMode = NavigationCacheMode.Enabled;
        SizeChanged += MainPage_SizeChanged;
    }


     protected override  void OnNavigatedTo(NavigationEventArgs e)
     {
        //await LoadInAppPurchaseProxyFileAsync();

     }  

    protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
    {

        if (licenseChangeHandler != null)
        {
            CurrentApp.LicenseInformation.LicenseChanged -= licenseChangeHandler;
        }
        base.OnNavigatingFrom(e);
    }       

    public void NotifyUser(string strMessage, NotifyType type)
    {

    }

    private async void BuyProduct2_Click(object sender, RoutedEventArgs e)
    {

        LicenseInformation licenseInformation = CurrentApp.LicenseInformation;
        if (!licenseInformation.ProductLicenses[ProductId].IsActive)
        {
            NotifyUser("Buying Product 2...", NotifyType.StatusMessage);
            try
            {
                await CurrentApp.RequestProductPurchaseAsync(ProductId);
                if (licenseInformation.ProductLicenses[ProductId].IsActive)
                {
                    NotifyUser("You bought Product 2.", NotifyType.StatusMessage);
                    foreach (String s in video)
                    {
                        Button button = (Button)FindControl<Button>(masterHub, s);
                        button.Visibility = Visibility.Collapsed;

                    }
                }
                else
                {

                    NotifyUser("Product 2 was not purchased.", NotifyType.StatusMessage);
                }
            }
            catch (Exception)
            {

                NotifyUser("Unable to buy Product 2.", NotifyType.ErrorMessage);
            }
        }
        else
        {
            NotifyUser("You already own Product 2.", NotifyType.ErrorMessage);

            foreach (String s in video)
            {
                Button button = (Button)FindControl<Button>(masterHub, s);
                button.Visibility = Visibility.Collapsed;

            }
        }
    }

我对 Windows 应用商店应用程序开发还很陌生,甚至对 Windows Phone 开发也很陌生。任何帮助将不胜感激。

【问题讨论】:

  • 错误信息在哪里显示?
  • 在设备上,在应用程序上,通过按钮选择购买后。
  • 我的意思是代码中发生错误的地方:)
  • 是的,伙计,如果我知道我现在不会在这里发帖,我会吗? :D 无论如何,没有异常/错误被抛出/显示。该应用程序构建干净的 AFAIK。
  • 这是在已发布的应用程序中发生还是在您测试/开发它时发生? stackoverflow.com/q/20846293/33051

标签: c# xaml windows-phone-8.1 win-universal-app


【解决方案1】:

我们必须检查是否在 Windows Phone 商店中正确创建了应用内产品,并检查 productId 是否正确。

【讨论】:

    猜你喜欢
    • 2023-04-03
    • 2015-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-21
    相关资源
    最近更新 更多