今すぐストアに入れたい Windows 8 アプリがあります。AppSimulator は正常に動作します ([OK] をクリックしたときに IsActive を [true] に設定することはできませんが、MsgDialog の [Thanks] がポップアップ表示されます) が、CurrentApp が正しいかどうかはわかりません。コードで IsActive を割り当てることなく、自動的に true に設定されることを既に読んだことがあります。
以下のコードに関して 2 つの質問があります。
CurrentApp のコードは機能しますか?
Windows はこの情報をストアから自動的に読み込んでいるため (本当かどうかはわかりません...どこかで読んだことがあります)、CurrentApp に関しては WindowsStoreProxy.xml に何も割り当てていません。 ProductLicenses が WindowsStoreProxy.xml で「Premium」と呼ばれていると言いますか? CurrentAppSimulator では、内部 XML ファイル in-app-purchase.xml から価格/名前/... をロードしているので簡単ですが、実際のアプリの XML ファイルを設定するにはどうすればよいですか? Windowsストアで?
#if DEBUG
StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("data");
StorageFile proxyFile = await proxyDataFolder.GetFileAsync("in-app-purchase.xml");
licenseChangeHandler = new LicenseChangedEventHandler(InAppPurchaseRefreshScenario);
CurrentAppSimulator.LicenseInformation.LicenseChanged += licenseChangeHandler;
await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile);
#endif
#if DEBUG
LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;
ListingInformation productListing = await CurrentAppSimulator.LoadListingInformationAsync();
#else
LicenseInformation licenseInformation = CurrentApp.LicenseInformation;
ListingInformation productListing = await CurrentApp.LoadListingInformationAsync();
#endif
ProductLicense productLicense = licenseInformation.ProductLicenses["Premium"];
if (!productLicense.IsActive)
{
Buy()
}
else
{
//use full function
}
private async void Buy()
{
#if DEBUG
LicenseInformation licenseInformation = CurrentAppSimulator.LicenseInformation;
#else
LicenseInformation licenseInformation = CurrentApp.LicenseInformation;
#endif
if (!licenseInformation.ProductLicenses["Premium"].IsActive)
{
try
{
#if DEBUG
await CurrentAppSimulator.RequestProductPurchaseAsync("Premium", false);
#else
await CurrentApp.RequestProductPurchaseAsync("Premium", false);
#endif
if (licenseInformation.ProductLicenses["Premium"].IsActive)
{
try
{
MessageDialog msgDialog = new MessageDialog("Thanks for buying the app.");
await msgDialog.ShowAsync();
}
catch
{
}
}
else
{
MessageDialog msgDialog = new MessageDialog("The purchase was cancelled.");
await msgDialog.ShowAsync();
}
}
catch
{
MessageDialog msgDialog = new MessageDialog("Connection error.");
msgDialog.ShowAsync();
}
}
else
{
MessageDialog msgDialog = new MessageDialog("You already have this feature.");
await msgDialog.ShowAsync();
}
}