收藏
回答

uniapp使用uni.getUpdateManager无法检测到小程序更新?

小程序旧版本:1.0.0

发布新版本后未1.0.1

如果是在微信模拟器中设置下一次编译模拟更新,就可以检测到,但是正式发布后,有版本更新就无法检测到。

app.vue 的代码如下:

在onShow中:

const updateManager = uni.getUpdateManager();
				// 请求版本信息
				updateManager.onCheckForUpdate(res => {
					if (res.hasUpdate) {
						uni.showModal({
							content: '新版本已经准备好,是否重启应用?',
							showCancel: false,
							confirmText: '确定',
							success: res => {
								if (res.confirm) {
									updateManager.onUpdateReady(function(res) {
										updateManager.applyUpdate();
									});
									updateManager.onUpdateFailed(res => { // 新版本下载失败的回调
										// 新版本下载失败,提示用户删除后通过冷启动重新打开
										uni.showModal({
											content: '下载失败,请删除当前小程序后重新打开',
											showCancel: false,
											confirmText: '知道了'
										})
									})
								}
							}
						})
					}
				})


回答关注问题邀请回答
收藏

2 个回答

  • 红薯
    红薯
    2023-08-18

    原生的是可以的,就是有时候会有点延迟,最多十分钟吧

    2023-08-18
    有用 1
    回复 1
    • K
      K
      2023-08-18
      按理说uniapp编译微信小程序应该是没问题吧,我是全量发布的,可能就是延时问题?微信官方有说明过这个的延迟时间范围吗?
      2023-08-18
      回复
  • 一笑皆春
    一笑皆春
    2023-08-18

    刚发布的小程序会有同步的时间

    2023-08-18
    有用
    回复
登录 后发表内容