Update Mechanism
Silent update
After the developer releases a new version of the mini-game in the management background, if a user has a historical version of the mini-game locally, the old version may still be opened at this time. The host app will have several opportunities to check whether there is an updated version of the mini-game cached locally, and if there is, it will be silently updated to the new version. In general, after the developer releases a new version in the background, it cannot immediately affect all existing network users, but in the worst case, the new version information will be sent to the user within 24 hours after the release. The next time the user opens it, it will first update the latest version and then open it.
Update when not started
The host app will regularly check whether the mini-games used recently have a new version released; if so, it will be updated to the new version synchronously the next time it is opened. This can ensure that all mini-games can use the latest version 24 hours after the new version is released.
Update at startup
Every time the mini-game is cold-started, it will check whether there is an updated version. If a new version is found, the new version of the code package will be downloaded asynchronously and started with the local package of the client at the same time, that is, the new version of the mini-game will not be applied until the next cold start.
Forced update
If the user needs to apply the latest version immediately, you can use the following methods:
Detection update API
You can usewx.getUpdateManagerAPI for processing.
const updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
// Callback upon requesting new version information
console.log(res.hasUpdate);
});
updateManager.onUpdateReady(function() {
wx.showModal({
title: "Update available",
content: "A new version is ready. Would you like to restart the app?",
success(res) {
if (res.confirm) {
// The new version has been downloaded, call applyUpdate to apply the new version and restart
updateManager.applyUpdate();
}
}
});
});
updateManager.onUpdateFailed(function() {
// Callback for failed new version download
...Debug API: The developer tool provides the debugging capability of forced update. Through compilation mode - edit compilation mode - check Simulate update at next compilation to debug the forced update function on the developer tool (real machine cannot be debugged).