当前位置:网站首页>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 .
边栏推荐
- 这5个摸鱼神器太火了!程序员:知道了快删!
- Blob 对象介绍
- Topic not received? Try this
- Rust versus go (which is my preferred language?)
- Explore dry goods! Apifox construction ideas
- Niu Mei's mathematical problem --- combinatorial number
- Empire CMS collection Empire template program general
- [advanced digital IC Verification] command query method and common command interpretation of VCs tool
- 【数字IC验证快速入门】15、SystemVerilog学习之基本语法2(操作符、类型转换、循环、Task/Function...内含实践练习)
- Relevant data of current limiting
猜你喜欢

让Livelink初始Pose与动捕演员一致

青龙面板-今日头条

jeeSite 表单页面的Excel 导入功能

QT learning 28 toolbar in the main window

Explore dry goods! Apifox construction ideas

Linux server development, MySQL transaction principle analysis

Introduction to basic components of wechat applet

2022 welder (elementary) judgment questions and online simulation examination

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

【踩坑系列】uniapp之h5 跨域的问题
随机推荐
Thinkcmf6.0 installation tutorial
复杂网络建模(二)
Codeforce c.strange test and acwing
Li Kou interview question 04.01 Path between nodes
Quickly use Jacobo code coverage statistics
[UVM foundation] what is transaction
LeetCode中等题之我的日程安排表 I
Find the mode in the binary search tree (use medium order traversal as an ordered array)
【數字IC驗證快速入門】15、SystemVerilog學習之基本語法2(操作符、類型轉換、循環、Task/Function...內含實踐練習)
Introduction à l'objet blob
复杂网络建模(一)
Main window in QT learning 27 application
JS cross browser parsing XML application
【踩坑系列】uniapp之h5 跨域的问题
Network learning (II) -- Introduction to socket
Network learning (III) -- highly concurrent socket programming (epoll)
太真实了,原来自己一直没有富裕起来是有原因的
padavan手动安装php
Qt学习27 应用程序中的主窗口
json 数据展平pd.json_normalize