当前位置:网站首页>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 .
边栏推荐
- game攻防世界逆向
- Implementation of replacement function of shell script
- C language flight booking system
- Force buckle 145 Binary Tree Postorder Traversal
- Search for an element in a binary search tree (BST)
- Recursive method constructs binary tree from middle order and post order traversal sequence
- Few shot Learning & meta learning: small sample learning principle and Siamese network structure (I)
- Recursive method to verify whether a tree is a binary search tree (BST)
- Who has docker to install MySQL locally?
- Blob 對象介紹
猜你喜欢

数据库实时同步利器——CDC(变化数据捕获技术)

【数字IC验证快速入门】14、SystemVerilog学习之基本语法1(数组、队列、结构体、枚举、字符串...内含实践练习)

Network learning (III) -- highly concurrent socket programming (epoll)

MySQL multi column index (composite index) features and usage scenarios

青龙面板-今日头条

Jmeter 的使用

Leetcode 40: combined sum II

2022制冷与空调设备运行操作复训题库及答案

Linux server development, redis protocol and asynchronous mode

JSON data flattening pd json_ normalize
随机推荐
[quick start of Digital IC Verification] 17. Basic grammar of SystemVerilog learning 4 (randomization)
Rust versus go (which is my preferred language?)
互动送书-《Oracle DBA工作笔记》签名版
Linux server development, redis source code storage principle and data model
Introduction à l'objet blob
【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
Avatary的LiveDriver试用体验
Myabtis_Plus
paddlepaddle 29 无模型定义代码下动态修改网络结构(relu变prelu,conv2d变conv3d,2d语义分割模型改为3d语义分割模型)
Real time monitoring of dog walking and rope pulling AI recognition helps smart city
Merging binary trees by recursion
The zblog plug-in supports the plug-in pushed by Baidu Sogou 360
快解析内网穿透为文档加密行业保驾护航
Content of string
C语言队列
Custom class loader loads network class
Li Kou interview question 04.01 Path between nodes
Linux server development, MySQL stored procedures, functions and triggers
让Livelink初始Pose与动捕演员一致
The charm of SQL optimization! From 30248s to 0.001s