当前位置:网站首页>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 .
边栏推荐
- [quick start of Digital IC Verification] 17. Basic grammar of SystemVerilog learning 4 (randomization)
- LeetCode中等题之我的日程安排表 I
- Padavan manually installs PHP
- 2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers
- 【数字IC验证快速入门】14、SystemVerilog学习之基本语法1(数组、队列、结构体、枚举、字符串...内含实践练习)
- Real time monitoring of dog walking and rope pulling AI recognition helps smart city
- 【数字IC验证快速入门】17、SystemVerilog学习之基本语法4(随机化Randomization)
- C language communication travel card background system
- 基于Pytorch 框架手动完成线性回归
- Yugu p1020 missile interception (binary search)
猜你喜欢

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

2022 Inner Mongolia latest advanced fire facility operator simulation examination question bank and answers

电池、电机技术受到很大关注,反而电控技术却很少被提及?

Li Kou interview question 04.01 Path between nodes

调用 pytorch API完成线性回归

jeeSite 表单页面的Excel 导入功能

Cnopendata American Golden Globe Award winning data

运放电路的反馈电阻上并联一个电容是什么作用

2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions

有 Docker 谁还在自己本地安装 Mysql ?
随机推荐
[quick start of Digital IC Verification] 15. Basic syntax of SystemVerilog learning 2 (operators, type conversion, loops, task/function... Including practical exercises)
LeetCode简单题之判断一个数的数字计数是否等于数位的值
快速使用 Jacoco 代码覆盖率统计
[UVM basics] summary of important knowledge points of "UVM practice" (continuous update...)
json 数据展平pd.json_normalize
jeeSite 表单页面的Excel 导入功能
Leetcode 90: subset II
调用 pytorch API完成线性回归
Recursive method to verify whether a tree is a binary search tree (BST)
Myabtis_Plus
C language flight booking system
央视太暖心了,手把手教你写HR最喜欢的简历
OpenJudge NOI 2.1 1752:鸡兔同笼
【数字IC验证快速入门】17、SystemVerilog学习之基本语法4(随机化Randomization)
Main window in QT learning 27 application
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
[quickstart to Digital IC Validation] 15. Basic syntax for SystemVerilog Learning 2 (operator, type conversion, loop, Task / Function... Including practical exercises)
【数字IC验证快速入门】12、SystemVerilog TestBench(SVTB)入门
JS quick start (I)
[Matlab] Simulink 自定义函数中的矩阵乘法工作不正常时可以使用模块库中的矩阵乘法模块代替