当前位置:网站首页>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 .
边栏推荐
- Linux server development, SQL statements, indexes, views, stored procedures, triggers
- 力扣(LeetCode)187. 重复的DNA序列(2022.07.06)
- [quick start of Digital IC Verification] 17. Basic grammar of SystemVerilog learning 4 (randomization)
- Numbers that appear only once
- MySQL multi column index (composite index) features and usage scenarios
- Thinkcmf6.0安装教程
- Lattice coloring - matrix fast power optimized shape pressure DP
- 2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions
- ROS Bridge 笔记(05)— carla_ackermann_control 功能包(将Ackermann messages 转化为 CarlaEgoVehicleControl 消息)
- C language flight booking system
猜你喜欢
电池、电机技术受到很大关注,反而电控技术却很少被提及?
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
Jmeter 的使用
微信小程序基本组件使用介绍
Empire CMS collection Empire template program general
【数字IC验证快速入门】13、SystemVerilog interface 和 program 学习
2022制冷与空调设备运行操作复训题库及答案
青龙面板-今日头条
Codeforce c.strange test and acwing
[matlab] when matrix multiplication in Simulink user-defined function does not work properly, matrix multiplication module in module library can be used instead
随机推荐
Linux server development, MySQL cache strategy
Chip design data download
Lattice coloring - matrix fast power optimized shape pressure DP
Qt学习27 应用程序中的主窗口
【数字IC验证快速入门】15、SystemVerilog学习之基本语法2(操作符、类型转换、循环、Task/Function...内含实践练习)
[quickstart to Digital IC Validation] 15. Basic syntax for SystemVerilog Learning 2 (operator, type conversion, loop, Task / Function... Including practical exercises)
buureservewp(2)
Network learning (I) -- basic model learning
The principle and implementation of buffer playback of large video files
Most elements
[UVM foundation] what is transaction
【数字IC验证快速入门】10、Verilog RTL设计必会的FIFO
These five fishing artifacts are too hot! Programmer: I know, delete it quickly!
让Livelink初始Pose与动捕演员一致
Linux server development, redis source code storage principle and data model
[UVM basics] summary of important knowledge points of "UVM practice" (continuous update...)
Network learning (II) -- Introduction to socket
Linux server development, MySQL index principle and optimization
电池、电机技术受到很大关注,反而电控技术却很少被提及?
通俗易懂单点登录SSO