Mini Program Forced Update

Note that the updated api of the applet requires the basic library to be above 1.9.90, and the children's shoes that need to be used remember to be compatible

1. Use in the onLaunch method of app.js:

    const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate( function (res) {
// Callback for requesting new version information
console.log(res.hasUpdate)
})

updateManager.onUpdateReady( function () {
wx.showModal({
title: 'Update prompt' ,
content: 'The new version is ready, do you want to restart the application? ' ,
success: function (res) {
if (res.confirm) {
// The new version has been downloaded, call applyUpdate to apply the new version and restart
updateManager.applyUpdate()
}
}
})

})

updateManager.onUpdateFailed( function () {
// Failed to download new version
wx.showModal({
title: 'Update prompt' ,
content: 'Failed to download new version' ,
showCancel: false
})
})


2. If the following error occurs, it means that the current basic library is not 1.9.90 or above


Need to modify the base library to 1.9.90



3. When compiling, remember to tick 'simulate update at next compilation (requires 1.9.90 and above basic library version)' to simulate the update effect


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324736577&siteId=291194637