当前位置:网站首页>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 .
边栏推荐
- 2022 recurrent training question bank and answers of refrigeration and air conditioning equipment operation
- The charm of SQL optimization! From 30248s to 0.001s
- Network learning (III) -- highly concurrent socket programming (epoll)
- 复杂网络建模(一)
- jeeSite 表单页面的Excel 导入功能
- Rust versus go (which is my preferred language?)
- 青龙面板--花花阅读
- 基于Pytorch 框架手动完成线性回归
- 快速使用 Jacoco 代码覆盖率统计
- Introduction à l'objet blob
猜你喜欢

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

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

game攻防世界逆向

【数字IC验证快速入门】17、SystemVerilog学习之基本语法4(随机化Randomization)

Ansible

2022 tea master (intermediate) examination questions and mock examination

【数字IC验证快速入门】13、SystemVerilog interface 和 program 学习

Es FAQ summary

央视太暖心了,手把手教你写HR最喜欢的简历

Force buckle 145 Binary Tree Postorder Traversal
随机推荐
Recursive method to construct binary tree from preorder and inorder traversal sequence
Thinkcmf6.0安装教程
调用 pytorch API完成线性回归
LeetCode简单题之字符串中最大的 3 位相同数字
ROS bridge notes (05) - Carla_ ackermann_ Control function package (convert Ackermann messages into carlaegovehiclecontrol messages)
复杂网络建模(三)
[matlab] when matrix multiplication in Simulink user-defined function does not work properly, matrix multiplication module in module library can be used instead
2022制冷与空调设备运行操作复训题库及答案
2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers
JSON data flattening pd json_ normalize
JS quick start (I)
Empire CMS collection Empire template program general
船载雷达天线滑环的使用
Roulette chart 2 - writing of roulette chart code
Es FAQ summary
2022焊工(初级)判断题及在线模拟考试
Summary of redis functions
Recursive method to verify whether a tree is a binary search tree (BST)
offer收割机:两个长字符串数字相加求和(经典面试算法题)
Who has docker to install MySQL locally?