After the release small updates online or the old version before

Small micro-channel program updates after each release line or an old version before, re-open after the new version appears to be deleted , especially annoying.

Do not know if too long did not see the document, found in increased api update wx.getUpdateManager (), then immediately try.

App.js increase in the life cycle of a onLaunch function, and then this example code is lost in the micro channel, check the "next compile simulation update", the effect can be seen in the compile-time compilation mode.

The App ({ 
    OnLaunch: function () { 
        const = updatemanager wx.getUpdateManager () 
    
        updateManager.onCheckForUpdate (function (RES) { 
            // End of the new version for a callback request 
            the console.log (res.hasUpdate) 
        }) 
 
        updateManager.onUpdateReady (function () { 
            wx.showModal ({ 
                title: 'update prompt', 
                Content: 'the new version is ready, whether to restart the application?', 
                Success: function (RES) { 
                    iF (res.confirm) { 
                        new version has been // Download well, call the new version of the application and restart applyUpdate 
                        updateManager.applyUpdate () 
                    } 
                } 
              }) 
        })
  
        UpdateManager.onUpdateFailed (function () { 
          // failed to download the new version 
        }) 
    } 
})

Upload time code to bring the version number, and whether the micro-channel will be the version number is determined according to the new version.

 



Original link: https: //blog.csdn.net/username_xu/article/details/84075333

Guess you like

Origin www.cnblogs.com/520BigBear/p/11262164.html