Javascript - Windows 商店 - 强制强制更新
Javascript - Windows Store - Forcing Mandatory Update
Javascript:
我希望我的 Windows 商店应用检查更新,尤其是强制更新,然后提示用户更新。
我发现这涉及到 Windows.Services.Store
,但我找不到任何 javascript 如何完成的示例,只有通常的 c#/vb 示例。
有人知道代码模板吗?
I have found out this involves Windows.Services.Store
, but I cannot find any javascript examples of how this is done, only the usual c#/vb ones.
我假设您找到的示例是 Code examples in Download and install package updates for your app。虽然,这些示例是用 C# 编写的,但我们可以轻松地将它们转换为 JavaScript,因为它们大多数是 Windows 运行时 API。
例如,使用下载并安装所有软件包更新,JavaScript 版本需要以下内容:
var context = Windows.Services.Store.StoreContext.getDefault();
context.getAppAndOptionalStorePackageUpdatesAsync().then(function (updates) {
if (updates.size > 0) {
var dialog = new Windows.UI.Popups.MessageDialog("Download and install updates now? This may cause the application to exit.", "Download and Install?");
dialog.commands.append(new Windows.UI.Popups.UICommand("Yes"));
dialog.commands.append(new Windows.UI.Popups.UICommand("No"));
dialog.showAsync().then(function (command) {
if (command.label === "Yes") {
context.requestDownloadAndInstallStorePackageUpdatesAsync(updates).then(function (result) {
// TODO
}, function (error) {
//TODO
}, function (progress) {
var downloadProgressBar = document.getElementById("downloadProgressBar");
downloadProgressBar.value = progress.packageDownloadProgress;
});
}
});
}
});
C# 和 JavaScript 版本之间的两个主要区别是 casing conventions and asynchronous methods. For more info, please see Using the Windows Runtime in JavaScript。
Javascript:
我希望我的 Windows 商店应用检查更新,尤其是强制更新,然后提示用户更新。
我发现这涉及到 Windows.Services.Store
,但我找不到任何 javascript 如何完成的示例,只有通常的 c#/vb 示例。
有人知道代码模板吗?
I have found out this involves
Windows.Services.Store
, but I cannot find any javascript examples of how this is done, only the usual c#/vb ones.
我假设您找到的示例是 Code examples in Download and install package updates for your app。虽然,这些示例是用 C# 编写的,但我们可以轻松地将它们转换为 JavaScript,因为它们大多数是 Windows 运行时 API。
例如,使用下载并安装所有软件包更新,JavaScript 版本需要以下内容:
var context = Windows.Services.Store.StoreContext.getDefault();
context.getAppAndOptionalStorePackageUpdatesAsync().then(function (updates) {
if (updates.size > 0) {
var dialog = new Windows.UI.Popups.MessageDialog("Download and install updates now? This may cause the application to exit.", "Download and Install?");
dialog.commands.append(new Windows.UI.Popups.UICommand("Yes"));
dialog.commands.append(new Windows.UI.Popups.UICommand("No"));
dialog.showAsync().then(function (command) {
if (command.label === "Yes") {
context.requestDownloadAndInstallStorePackageUpdatesAsync(updates).then(function (result) {
// TODO
}, function (error) {
//TODO
}, function (progress) {
var downloadProgressBar = document.getElementById("downloadProgressBar");
downloadProgressBar.value = progress.packageDownloadProgress;
});
}
});
}
});
C# 和 JavaScript 版本之间的两个主要区别是 casing conventions and asynchronous methods. For more info, please see Using the Windows Runtime in JavaScript。