0
点赞
收藏
分享

微信扫一扫

uniapp接收通知,检查版本更新

APP.vue的onLaunch中

// 锁定竖屏
plus.screen.lockOrientation("portrait-primary");

const _handlePush = function(message) {
plus.push.createMessage(msg.title, msg.content);
// uni.navigateTo({
// url: '/pages/index/index'
// });
};
plus.push.addEventListener('click', _handlePush);
plus.push.addEventListener('receive', _handlePush);

uni.request({
url: this.globalData+'/banben/CheckVersion',
method: 'GET',
success: res => {
let versionInfo=res.data.value
if (plus.runtime.version != versionInfo.Banben) {
let con=''
for(let i=0;i<versionInfo.Content.length;i++){
con+=versionInfo.Content[i]+'\n'
}
uni.showModal({
title: '孤鸽社区 更新',
content: con,
success: showResult => {
const downloadTask = uni.downloadFile({
// url:this.globalData+'/sta/'+versionInfo.Banben+'.apk',
url: 'https://download.autonavi.com/amap/package/C3060/Amap_V11.18.1.2936_android_C3060_(Build2207071529-64).apk',
success: (res) => {
if (res.statusCode === 200) {
plus.runtime.install(res.tempFilePath,{force:true},function(){
plus.runtime.restart();
},function(e){
console.log("failed: "+e.message);
});
}
},fail(f) {
console.log("=========下载====f====",f)
}
});

downloadTask.onProgressUpdate((res) => {
this.pg = res.progress
});
}
});
}
},
});

举报

相关推荐

0 条评论