function checkUpdateVersion() {
if (wx.canIUse('getUpdateManager')) {
const updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate(function (res) {
if (res.hasUpdate) {
updateManager.onUpdateReady(function () {
wx.showModal({
title: '温馨提示',
content: '检测到新版本,是否重启小程序?',
showCancel: false,
success: function (res) {
if (res.confirm) {
updateManager.applyUpdate();
}
},
});
});
updateManager.onUpdateFailed(function () {
wx.showModal({
title: '已有新版本',
content: '请您卸载小程序,重新搜索进入',
showCancel: false,
confirmText: '知道了',
});
});
}
});
} else {
wx.showModal({
title: '温馨提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
});
}
}
module.exports = {
checkUpdateVersion,
};
大多数情况是自动静默更新的
https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/update-mechanism.html
IOS 不提示,直接重启更新?
安卓那个是不是打开之前没偷偷更新
安卓和ios的运行机制不一样,我感觉安卓挂载应用时间比较长,ios经常杀应用