UpdateManager.downloadNew
Introduction
Initiate the download of the latest version of the mini-program. This is effective after actively initiating an AppInfo request, i.e., using UpdateManager.forceUpdateAppInfo()
.
Parameters
None
Sample Code
Page({
onLoad() {
const updateManager = dlt.getUpdateManager();
updateManager.forceUpdateAppInfo({
success: function (res) {
// Check if there is a new version update
if (res.hasUpdate) {
// Initiate the download of the latest mini-program package
updateManager.downloadNew({
success: (res) => {
if (res.hasReady) {
dlt.showModal({
title: 'Update Prompt',
content:
'A new version is ready. Do you want to restart the application?',
success: function (res) {
if (res.confirm) {
// The new version is downloaded and ready; call applyUpdate to apply the new version and restart.
updateManager.applyUpdate();
}
},
});
}
},
fail: (res) => {},
complete: (res) => {},
});
}
},
fail: function (res) {},
complete: function (res) {},
});
},
});