字节跳动小程序开发API UpdateManager使用无效
593 浏览2020年05月28日作者:wtsbxdx-666

报错截图或相关BUG
在此处粘贴截图
使用官方的例子,image.png
控制台不会打印onCheckForUpdate,说明没有进updateManager.onCheckForUpdate这个方法,打印updateManager
如图:image.png
就是进不去updateManager.onCheckForUpdate这个方法

复现步骤

  • 第1步...
  • 第2步...
  • ...

const updateManager = tt.getUpdateManager();
        console.log("updateManager",updateManager);
        updateManager.onCheckForUpdate(function(res) {
        // 请求完新版本信息的回调
        console.log("onCheckForUpdate", res.hasUpdate);
        if (res.hasUpdate) {
            tt.showToast({
            title: "即将有更新请留意"
            });
        }
        });

        updateManager.onUpdateReady(() => {
        tt.showModal({
            title: "更新提示",
            content: "新版本已经准备好,是否立即使用?",
            success: function(res) {
            if (res.confirm) {
                // 调用 applyUpdate 应用新版本并重启
                updateManager.applyUpdate();
            } else {
                tt.showToast({
                icon: "none",
                title: "小程序下一次「冷启动」时会使用新版本"
                });
            }
            }
        });
        });

        updateManager.onUpdateFailed(() => {
        tt.showToast({
            title: "更新失败,下次启动继续..."
        });
        });

最后一次编辑于 2020 年 06 月 29 日
共 3 条评论

相关问答

专题推荐

热门文章

热门问答