title: Taro.getUpdateManager()

sidebar_label: getUpdateManager

Obtains the globally unique version update manager, which is used to manage Mini Program updates. For more information about the Mini Program update mechanism, see the Operating Mechanism documentation.

Reference

Type

  1. () => UpdateManager

Parameters

Sample Code

  1. const updateManager = Taro.getUpdateManager()
  2. updateManager.onCheckForUpdate(function (res) {
  3. console.log(res.hasUpdate)
  4. })
  5. updateManager.onUpdateReady(function () {
  6. Taro.showModal({
  7. title: 'Update Tips',
  8. content: 'The new version is ready, is the app restarted?',
  9. success: function (res) {
  10. if (res.confirm) {
  11. // The new version has been downloaded, call applyUpdate to apply the new version and restart.
  12. updateManager.applyUpdate()
  13. }
  14. }
  15. })
  16. })
  17. updateManager.onUpdateFailed(function () {
  18. // Download of the new version has failed
  19. })

API Support

API WeChat Mini-Program H5 React Native
Taro.getUpdateManager ✔️