0

シミュレーターでアプリ購入のテストを実装しようとしましたが、すべて無駄でした。ストアの例は機能しますが、アプリに同様の動作を実装しようとすると、どういうわけか思い通りにシミュレートされません。プレミアム機能として作成する必要がある設定ページとすべてのメモ ページがあります。アプリはデフォルトで無料です。

これは私のxmlファイルです。サンプルアプリにあるものをそのまま作成しました。私のアプリはデフォルトで無料なので必要ですか?

<?xml version="1.0" encoding="utf-8" ?>
<CurrentApp>
  <LicenseInformation>
    <App>
      <IsActive>true</IsActive>
      <IsTrial>false</IsTrial>
    </App>
  <Product ProductId="Settings">
    <IsActive>true</IsActive>
  </Product>
  <Product ProductId="AllNotes">
   <IsActive>false</IsActive>
  </Product>
</LicenseInformation>
</CurrentApp>

コードの残りの部分は、設定ページの OnNavigatedTo 関数に記述されています。

protected override async void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);

    StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Data");
    StorageFile proxyFile = await proxyDataFolder.GetFileAsync("in-app-purchase.xml");
    LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;
    var productLicense = licenseInformation.ProductLicenses["Settings"];


    if (!productLicense.IsActive)
    {
        var messageDialog = new MessageDialog("You need to buy the Settings option", "Buy");
        messageDialog.Commands.Add(new UICommand("Buy", null, 0));

        var commandChosen = await messageDialog.ShowAsync();

        if ((int)commandChosen.Id == 0)
        {
            await CurrentAppSimulator.RequestProductPurchaseAsync("Settings", true);
            if (licenseInformation.ProductLicenses["Settings"].IsActive)
            {
                InitializeUI();
            }
        }
    }
}

だから商品を買おうとしても待ってる

CurrentAppSimulator.RequestProductPurchaseAsync("Settings", true); 

値はまだ false です。私が見逃しているものはありますか?

4

2 に答える 2

0

proxyFile を CurrentAppSimulator にロードするのを忘れました。

await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile);
于 2014-12-30T09:26:40.947 に答える
0

IsTrial == Trueそれが問題かどうかはわかりませんが、xmlに入れました。しかし、私が見つけた、そしてもっと重要なことは、何かを正常に購入できるようにするには、最初にアプリ自体を購入する必要があることです。

Windows.ApplicationModel.Store.CurrentAppSimulator.RequestAppPurchaseAsync()

これはセッション中に 1 回だけ行う必要があり、アプリを購入した後は、任意の製品を購入できます。お役に立てれば。

于 2014-08-29T03:41:22.993 に答える