Skip to main content
Get an UpdateManager instance to manage Mini Program updates.

Return Value

Returns an UpdateManager object.

UpdateManager Methods

MethodDescription
onCheckForUpdate(callback)Called when update check completes
onUpdateReady(callback)Called when new version is downloaded
onUpdateFailed(callback)Called when update download fails
applyUpdate()Force apply and restart with new version

Code Example

const updateManager = my.getUpdateManager();

updateManager.onCheckForUpdate((res) => {
  console.log('Has update:', res.hasUpdate);
});

updateManager.onUpdateReady(() => {
  my.confirm({
    title: 'Update Available',
    content: 'Restart to apply the new version?',
    success: (res) => {
      if (res.confirm) {
        updateManager.applyUpdate();
      }
    }
  });
});

updateManager.onUpdateFailed(() => {
  console.log('Update download failed');
});