Minigame Update Mechanism
After a developer publishes a new version, the OpenPaaS SDK ensures that users eventually use the latest version through silent updates or startup updates.
Silent Update Mechanism
After a new version of the game is published in the background, the OpenPaaS SDK checks for and applies updates at multiple points in time.
- Update while not running: the OpenPaaS SDK periodically checks the most recently used minigames. If a new version is available, it is synchronized automatically, ensuring that the user gets the latest version the next time they open it.
Update at Startup
The OpenPaaS SDK checks for updates on every cold start:
- Update found: the new version code package is downloaded asynchronously.
- Current run: this startup still uses the old version package stored locally on the client.
- Apply timing: the new version is not applied until the next cold start.
Forced Update
If you need users to apply the latest version immediately, you can use the following two approaches
Update Detection API
You can use the sud.getUpdateManager API to handle this.
const updateManager = sud.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
// Callback after new version information has been requested
console.log(res.hasUpdate);
});
updateManager.onUpdateReady(function() {
sud.showModal({
title: "Update Prompt",
content: "A new version is ready. Restart the game now?",
success(res) {
if (res.confirm) {
// The new version has been downloaded; call applyUpdate to apply it and restart
updateManager.applyUpdate();
}
}
});
});
updateManager.onUpdateFailed(function() {
// New version download failed
});Debugging API: the developer tool provides the ability to debug forced updates. Via Compile Mode - Edit Compile Mode - check "Simulate update on next compile," you can debug the forced update feature in the developer tool (it cannot be debugged on a real device).
Setting the Minimum Available Version
- If you want users to always open the latest version, you can go to [OpenPaaS Backend - Settings - Basic Settings - OpenPaaS Minimum Available Version] and change it to the latest version
