3***@qq.com
3***@qq.com
  • 发布:2020-03-18 10:34
  • 更新:2021-04-18 20:03
  • 阅读:2219

plus.runtime.install 无法安装 无报错信息

分类:HBuilderX
onLoad() {  
            this.update();  
        },  
        methods: {  
            update() {  
                if (this.button === '正在更新') return;  
                this.button = '正在更新';  
                /* 准备更新 */  
                let that = this;  
                /* 初始化 */  
                this.dtask = plus.downloader.createDownload(this.url, {}, function(d, status) {  
                    // console.log(JSON.stringify(d));  
                    // 下载完成    
                    if (status == 200) {  
                        // uni.setStorageSync("appFile", {  
                        //  ver: that.ver,  
                        //  path: d.filename  
                        // });  
                        plus.runtime.install(plus.io.convertLocalFileSystemURL(d.filename), {}, {}, function(error) {  
                            // console.log('error:', error)  
                            // 如果安装本地文件失败, 下载最新文件安装  
                            that.failed();  
                        })  
                    } else {  
                        that.failed();  
                    }  
                });  
                /* 开始更新 */  
                // let file = uni.getStorageSync('appFile');  
                // console.log(file)  
                // 使用本地文件更新  
                // if (file && file.ver == this.ver) {  
                //  this.button = '安装更新';  
                //  this.install(file.path, true);  
                // }  
                // 下载新文件  
                // else {  
                    // 更新进度  
                    this.dtask.addEventListener('statechanged', this.progress);  
                    this.dtask.start();  
                // }  
            },  
            /* 安装进度 */  
            progress(task) {  
                if (!this.dtask) return;  
                switch (task.state) {  
                    case 1:  
                        this.text = '开始下载...';  
                        break;  
                    case 2:  
                        this.text = '下载中...';  
                        break;  
                    case 3:  
                        let progressVal = 0;  
                        progressVal = Math.ceil(task.downloadedSize / task.totalSize * 100);  
                        if (progressVal == 100) {  
                            this.text = '下载完成...';  
                        } else {  
                            this.text = '下载 ' + progressVal + '%';  
                        }  
                        break;  
                    case 4:  
                        this.text = '开始安装...';  
                        break;  
                }  
            },  
            /* 安装失败 */  
            failed() {  
                uni.showToast({  
                    icon: "none",  
                    mask: true,  
                    title: '更新失败!请退出重试或向工作人员反映',  
                    duration: 1500  
                });  
                setTimeout(function() {  
                    plus.runtime.quit()  
                }, 1500);  
            }  
        }
2020-03-18 10:34 负责人:无 分享
已邀请:
3***@qq.com

3***@qq.com (作者)

已解决

2***@qq.com

2***@qq.com - 后端猿,学点前端

大佬怎么解决的?求方法,这两天我快被这个问题折磨疯了。。。我的下载更新代码跟贴中的几乎一样,且没有改动过,突然从某个版本开始就无法弹出安装了(下载完成后未自动执行安装),也不报错。。

  • 3***@qq.com (作者)

    我这边排查不出来错误, 最后定位到是 编辑器版本的问题. 我从 2.6.5 换到 2.5.1 就可以用了

    2020-03-20 11:08

  • 1***@qq.com

    我这边是有的手机可以按装,有的手机不可以。我也没升级编辑器版本。就突然不可以了。不知道是什么原因

    2020-06-23 11:19

  • 9***@qq.com

    回复 3***@qq.com: 请问还有这个问题吗?我这边编辑器已经是最新版本的了,部分手机还是出现这个问题

    2020-07-09 14:09

v***@qq.com

v***@qq.com

请问一下,我是这样写的,执行的是安装更新失败!失败返回的e为null, 可以帮我看看那错了吗?

素履之往独远行

素履之往独远行

我的IOS正式包plus.runtime.install 无法安装 无报错信息,请问楼主怎么解决了 ,我现在都用的编辑器3.1.6的版本了

  • 1***@qq.com

    iOS - 4.3+ (支持) :

    不支持ipa包的安装,需跳转appsotre引导用户手动操作安装。

    2021-09-26 15:35

该问题目前已经被锁定, 无法添加新回复