当前位置:网站首页>Uni hot update
Uni hot update
2022-07-01 07:59:00 【diangedan】
// Check whether the version is updated
updateVersion() {
// Hot update will not update app Version number of
// Here we use a constant to define ( Each time you modify the version number, you will manually update the version number in the settings )
let realVersion = '1';
//plus.runtime.getProperty(), Get the locally installed version , Please refer to the following links for specific use
// https: //www.html5plus.org/doc/zh_cn/runtime.html#plus.runtime.WidgetInfo
plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
let currentVersion = widgetInfo.version.replace(/\./g, ""); // Get the current version number
sendVersion().then(res => {
const code = res.data.code;
if (code === 100) {
let newVersion = res.data.data.id;
let downloadUrl = res.data.data.downloadUrl;
if (realVersion < newVersion) {
uni.showModal({
title: ' A new version has been found ',
content: ' Confirm update ?',
success: function(res) {
if (res.confirm) {
uni.downloadFile({
url: downloadUrl,
success: (downloadResult) => {
plus.runtime.install(
downloadResult
.tempFilePath, {
force: true
},
function() {
// Application hot restart , Restart to enter the home page .
plus.runtime.restart();
uni.showModal({
title: ' Installation successful !',
content: ' Re entered the app ',
success: function(res) {
if (res.confirm) {
console.log(' The user clicks ok ');
} else if(res.cancel) {
console.log(' The user clicks cancel ');
}
}
});
// uni.hideToast();
},
function(e) {
uni.showToast({
title: ' Installation failed ',
icon: 'none'
})
})
},
fail: (err) => {
console.log(err)
uni.showToast({
title: ' Download failed ',
icon: 'none'
})
}
})
} else if (res.cancel) {
uni.showToast({
title: ' Cancelled ',
icon: 'none'
})
}
}
})
}
} else {
uni.showToast({
title: res.data.msg,
icon: 'none'
})
}
}).catch(err => {
console.log(err)
})
})
},
边栏推荐
- Tupu software has passed CMMI5 certification| High authority and high-level certification in the international software field
- 2022 test questions and mock examinations for main principals of hazardous chemicals business units
- 【mysql学习笔记27】存储过程
- [recommendation system] breakthrough and imagination of deep location interactive network dpin for meituan takeout recommendation scenario
- 漏刻有时API接口实战开发系列(14):身份证实名鉴权验证
- The database is locked. Is there a solution
- Contenttype comparison of all types
- 力扣每日一题-第32天-1822.数组元素积的符号
- 【mysql学习笔记28】存储函数
- Long way to go with technology
猜你喜欢
base64
MATLAB之基础知识
The Windows C disk is full
[kv260] generate chip temperature curve with xadc
postgresql源码学习(26)—— Windows vscode远程调试Linux上的postgresql
Atguigu---- scaffold --02- use scaffold (2)
The triode is a great invention
SharePoint - modify web application authentication using PowerShell
论文学习——水文时间序列相似性查询的分析与研究
PWN攻防世界int_overflow
随机推荐
Thesis learning -- Analysis and Research on similarity query of hydrological time series
Scala language learning-07-constructor
Android screen adaptation (using constraintlayout), kotlin array sorting
go通用动态重试机制解决方案的实现与封装
【力扣10天SQL入门】Day9 控制流
base64
2022 tea master (intermediate) recurrent training question bank and answers
【入门】提取不重复的整数
Aardio - Method of self constructed geticonhandle
Two expressions of string
2022茶艺师(初级)操作证考试题库及模拟考试
How to make the two financial transactions faster
Aardio - 自己构造的getIconHandle的方法
Caesar
Download xshell and xftp
Contenttype comparison of all types
2022年茶艺师(中级)复训题库及答案
[kv260] generate chip temperature curve with xadc
sqlalchemy创建MySQL_Table
良心安利万向轮 SolidWorks模型素材网站