Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to update the PHP version number automatically using the Appcan client

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "how to use the Appcan client to automatically update the PHP version number", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use the Appcan client to automatically update the PHP version number" this article.

In the project development process encountered app side automatic update, access to relevant materials and then the Appcan client automatically update the PHP version number of the method sorted out, the specific code is explained as follows.

Server files: update.php, version.php, version.xml

Update.php content:

PHP

Version.php content:

PHP

Version.xml content: PHP index.html client: PHPwindow.uexOnload = function (type) {if (! type) {update ();} var flag_sdcard = 1 posivar updateurl =''; / / download new apk file address var filepath3 = "/ sdcard/"; / / Save to SD card var fileName =''; / / New version file name var platform ='' / / platform version function update () {/ / Android version, showing download progress (step:7) uexDownloaderMgr.onStatus = function (opId, fileSize, percent, status) {if (status = = 0) {/ / downloading. Log ('download percent' + percent +'%'); uexWindow.toast ('1percent,' 5percent, 'downloading' + localStorage.app_title+' new version, please wait. Progress:'+ percent +'%',');} else if (status = = 1) {/ / download completed. UexWindow.closeToast (); uexDownloaderMgr.closeDownloader ('14'); / / close the download object uexWidget.installApp (filepath3+fileName); / / install the download apk file} else {uexWindow.toast (' 1 download,'5 download, 'download error, please close' + localStorage.app_title+' to run again.',');}} / / Android version, create download object callback function (step:6) uexDownloaderMgr.cbCreateDownloader = function (opId, dataType, data) {Log ('uexDownloaderMgr.cbCreateDownloader data='+data); if (data= = 0) {/ / updateurl is the uexDownloaderMgr.download (' 14, updateurl, filepath3+fileName,'0') that is put into the global variable after calling cbCheckUpdate callback / / start downloading apk file} else if (data = = 1) {;} else {;}; / / prompt to update the mode box button event callback function to determine whether the user chooses to update or cancel (step:5) uexWindow.cbConfirm = function (opId, dataType, data) {Log ('uexWindow.cbConfirm') / / call the dialog prompt function if (data = = 0) {/ / the user clicks the later button and does not update} else {/ / the user clicks the OK button to update the if (platform = = 0) {/ / Apple version update Load the appstore path uexWidget.loadApp (updateurl,'','') through the browser / / uexWidget.loadApp (",", updateurl); / / the old method is no longer available. } else if (platform = = 1) {/ / Android version update, download uexDownloaderMgr.createDownloader ("14") by creating download object;} else {;}} / / call the callback function to check for updates. After the request is successful, the pop-up modal box lets the user choose whether to update (step:4) uexWidget.cbCheckUpdate = function (opCode, dataType, jsonData) {Log ('jsonData='+jsonData); var obj = eval (' ('+ jsonData +')'); if (obj.result = = 0) {/ / tips = "update address is:" + obj.url + "

File name: "+ obj.name +"

File size: "+ / / obj.size +"

Version number: "+ obj.version; updateurl = obj.url; fileName = obj.name+" .apk "; getVersionContent (); / / var value =" later; update "; / / var mycars = value.split ("; "); / / uexWindow.confirm (', 'there is currently a new version, is it updated?', mycars) / / Pop-up prompt box to confirm whether to update} else if (obj.result = = 1) {/ / Apple / / alert ("update address is" + obj.url + ")

File name: "+ obj.name +"

File size: "+ / / obj.size +"

Version number: "+ obj.version); / / tips =" current version is up to date "; alert (tips);} else if (obj.result = = 2) {; / / tips =" unknown error "; alert (tips);} else if (obj.result = = 3) {; / / tips =" Parameter error "; alert (tips) }}; / / check whether the callback function of SD card (step:3) uexFileMgr.cbIsFileExistByPath = function (opCode, dataType, data) {Log ('uexFileMgr.cbIsFileExistByPath flag_sdcard='+flag_sdcard+', data='+data); if (flag_sdcard= = 0) {if (data= = 0) {Log (' sdcard does not exist, handle on a case-by-case basis') } else {/ / execute check update uexWidget.checkUpdate (); / / initiate http request} flag_sdcard = 1;} according to the check update address configured in config.xml / / get the platform version callback function to determine which platform client (step:2) uexWidgetOne.cbGetPlatform = function (opId, dataType, data) {Log ('uexWidgetOne.cbGetPlatform'); / / get the system version information callback function platform= data; Log ('platform=' + platform) If (data = = 0) {/ / is iphone uexWidget.checkUpdate (); / / directly calls to check for updates, checking that the update address is configured in config.xml} else if (data = = 1) {/ / is android flag_sdcard = 0; uexFileMgr.isFileExistByPath ('/ sdcard/') / / first determine whether the SD card exists, and then call checkUpdate to update} else {/ / platform}}; uexWidgetOne.getPlatform (); / obtain the platform version (step:1)} function Log (s) {uexLog.sendLog (s);} function getVersionContent () {var url = web_url+ "version.php"; uexXmlHttpMgr.onData = getvSuccess UexXmlHttpMgr.open (777, "get", url, "); uexXmlHttpMgr.send (777);} function getvSuccess (opid,status,result) {if (status==-1) {uexWindow.toast (" 0 "," 5 "," not connected to the network ^ _ ^ "," 3000 ");} if (status==1) {uexXmlHttpMgr.close (777); uexWindow.closeToast () If (result== "[]") {uexWindow.toast ("0", "5", "none", "2000");} else {var con=eval ('('+ result +')') var value = "later; update"; var mycars = value.split (";"); uexWindow.confirm (con.vtitle, con.vcontent, mycars); / / pop-up prompt box to confirm the update}

Finally, enter the config.xml file configuration update address of app as follows:

Http://www.i2ty.com/update.php

Update prompt on APP side:

The contents of the pop-up window can be customized according to the contents of the version.php file.

The above is all the contents of the article "how to use the Appcan client to automatically update the PHP version number". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report