Silent updates
When a developer releases a new version of a mini game through the management console, users who have an older version of the game locally may still open the old version. The host app will periodically check if there is an updated version of the locally cached mini game and, if so, will silently update to the new version. In general, after a developer releases a new version, it may not immediately affect all users, but in the worst case, the new version information will be delivered to users within 24 hours. The next time the user opens the game, it will first update to the latest version before launching.
Update before launch
The host app will periodically check if recently used mini games have a new version available. If there is a new version, it will update to the new version the next time the game is opened. This ensures that all mini games will use the latest version within 24 hours of the new version being released.
Update during launch
Every time a mini game cold starts, it will check for updates. If a new version is found, the new version's code package will be downloaded asynchronously while the game starts using the local package. The new version of the mini game will be applied the next time the game cold starts.
Forced updates
If you need users to immediately apply the latest version, you can use the following method:
Check and update the API
const updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
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) {
updateManager.applyUpdate();
}
}
});
});
updateManager.onUpdateFailed(function() {
...
Debug API: The developer tools provide the ability to force update for debugging purposes. By enabling "Simulate update on next compile" in the compile mode settings, you can test the forced update feature in the developer tools (this cannot be tested on a real device).