当前位置:网站首页>Uniapp mobile terminal forced update function
Uniapp mobile terminal forced update function
2022-07-07 08:08:00 【The sea of waves】
uniapp Forced update function of mobile terminal
background
lately , Considering the iterative upgrade of the mobile version , You need to have the function of forced update , The overall logic is relatively simple , I haven't done it before , So make a simple record .
front end
You need to open the mobile terminal app, It is necessary to judge the version number , So you need to be in app.vue In the document onLaunch() Method Writing code logic in .
// Force update
//#ifdef APP-PLUS
this.$u.api.update({
appid: plus.runtime.appid,
version: plus.runtime.versionCode
})
.then(res => {
console.log(res);
console.log(plus.runtime.appid);
console.log(plus.runtime.versionCode);
console.log(res.status);
if (res.status == 1) {
uni.showModal({ // Remind users to update
title: " Update hints ",
showCancel: false, // Hide the unhide button
content: res.note,
buttonText: ' determine ',
success: (rese) => {
if (rese.confirm) {
plus.runtime.openURL(res.url); // Call the browser on the mobile phone Download
}
}
})
}
});
//#endif
Back end
/**
* mandatory Update verification
* @param appid
* @param version
* @return
*/
@RequestMapping("/update")
public ResponseEntity<Map<String, String>> update(String appid, String version) {
Map<String, String> map = new HashMap<>();
// Get the upgraded version stored in the database , Upgrade content and download links
AppUpdateApk appUpdateApk = appUpdateApkService.findNew();
String mVersion = appUpdateApk.getVersionNumber();
// Version number of mobile terminal Compare with the latest version number of the database
if(mVersion.equals(version)){
map.put("status","0");
}else{
// Remind different
map.put("status","1");
map.put("note",appUpdateApk.getUpdateContent());
map.put("url",appUpdateApk.getUrl());
}
return ResponseEntity.ok(map);
}
Last
I believe there must be other better methods , Comments are welcome , Learn from each other together .
边栏推荐
- Li Kou interview question 04.01 Path between nodes
- ZCMU--1492: Problem D(C语言)
- Blob 对象介绍
- Real time monitoring of dog walking and rope pulling AI recognition helps smart city
- Introduction to basic components of wechat applet
- Padavan manually installs PHP
- Zsh shell adds automatic completion and syntax highlighting
- 数据库实时同步利器——CDC(变化数据捕获技术)
- buureservewp(2)
- 贝叶斯定律
猜你喜欢
Numbers that appear only once
2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers
Avatary的LiveDriver试用体验
Qt学习27 应用程序中的主窗口
王爽 《汇编语言》之寄存器
Custom class loader loads network class
mysql多列索引(组合索引)特点和使用场景
2022 tea master (intermediate) examination questions and mock examination
Leetcode 40: combined sum II
通俗易懂单点登录SSO
随机推荐
Linux Installation MySQL 8.0 configuration
MySQL multi column index (composite index) features and usage scenarios
The legend about reading the configuration file under SRC
Force buckle 145 Binary Tree Postorder Traversal
Linux server development, MySQL process control statement
LeetCode中等题之我的日程安排表 I
C language communication travel card background system
Merging binary trees by recursion
JSON data flattening pd json_ normalize
Linux server development, MySQL index principle and optimization
Myabtis_Plus
Custom class loader loads network class
Summary of redis functions
UnityHub破解&Unity破解
Notes on PHP penetration test topics
复杂网络建模(一)
jeeSite 表单页面的Excel 导入功能
OpenJudge NOI 2.1 1752:鸡兔同笼
【数字IC验证快速入门】12、SystemVerilog TestBench(SVTB)入门
game攻防世界逆向