About the Appcan auto-upgrade feature

Source: Internet
Author: User

We are now UAT environment of the app is made with Appcan and HTML5, a lot of friends are asking Uat app upgrade how to do

We're going to create a couple of variables in zy_control.js. The version representation is the revision number of the current app (note: Because Zy_control contains appcan some initialization code, each page needs to import this JS)

Every time we open the app, we call Appcan Widgetone on the Welcome screen to get platform-based judgment. is the current phone iOS or Android?


Uexwidgetone.getplatform ();//Get Platform Version (step:1) Uexwidgetone.cbgetplatform = function (Opid, dataType, data)                {var update = 0;                if (data = = 1) {update = 1;                } else {//I am iOS update = 2;                    } setstorage ("Sysos", update);//Put the current phone model into the cache $.ajax ({type: ' GET '),                    Url:apip + "/managerdemo/app/update.do?type=" + Update, DataType: ' JSON ',                    timeout:20000, Error:function () {msgprompt (Getlang ("Wlanerror"))  }, Success:function (data) {Console.log (data) if                        (data.msg = = 10000)                        {return;     } UpdateUrl = Data.appurl;                   Setstorage (' UpdateUrl ', updateurl);            Setstorage ("Remoteversion", data.version);/}}); };
Then initiate a request to the background get the latest version number get the latest version number based on incoming type and get the version number to cache



Setstorage ("Remoteversion", data.version);//

When the user clicks on the function according to the current version number and the remote version number inconsistent to download the operation IOS must jump to the URL to install

Checklogin:function () {var url=getstorage ("UpdateUrl"); if (menu.remoteversion! = null) {if (menu.remoteversion! = Version) {uexwindow.cbconfirm = function () {switch (Index_content.os) {case 1:beihai365_app_update (); Break;case 2: Uexwidget.loadapp (Url,null,null);}};            Uexwindow.confirm (Getlang ("suremsg"), Getlang ("Suertoupdate"), [Getlang ("Sure"), Getlang ("Nosure")]); return false;}}        return Menu.judgesessionid (); }function beihai365_app_update () {    var flag_sdcard = 1;    var fileName = ' AppPer.apk ' ;//new version filename     var updateurl = GetStorage ("updateurl") +filename;//download new apk file address     var Filepath2 = "/sdcard/";//Save to SD card     var platform1 = ";//Platform version     //var update_msg =" New version currently available , is it updated? ";  //Hint text          //Android version, show download Progress (STEP:7)     Uexdownloadermgr.onstatus = function (Opid, fileSize, percent, status) {       &Nbsp;    if (status = = 0) {                    //Download in ...                    //alert (' download percent ' + percent + '% ');                     Uexwindow.toast (' 1 ', ' 5 ', ' Download progress: ' + percent + '% ', ');            } else if (status = = 1) {//download complete .                     uexwindow.closetoast ();                     Uexdownloadermgr.closedownloader (' 14 ');// Close the Download object                     //localstoRage.clear ();                     //alert (filepath2+ FileName);                     Uexwidget.installapp (filepath2+filename);//install download APK file              else {                 & nbsp;   uexdownloadermgr.closedownloader (' 14 ');//Close the Download object                     //uexwindow.toast (' 1 ', ' 5 ', ' Please make sure the SD card is working properly . ', ');           }   };    //Android version, create a Download object callback function (step:6)     Uexdownloadermgr.cbcreatedownloader = function (Opid, DataType, Data) {           //alert (' Uexdownloadermgr. Cbcreatedownloader data= ' +data);            if (data = = 0) {                     //updateurl is put into global variables by calling the Cbcheckupdate callback after the                          uexdownloadermgr.download (' 14 ', UpdateUrl, Filepath2+filename, ' 0 ');//Start download apk file             } else if (data = = 1) {                    ;           } else {                    ;  }   };              // Check if the SD card callback function is already present (STEp:3)     Uexfilemgr.cbisfileexistbypath = function (OpCode, dataType, data) {            //alert (' Uexfilemgr.cbisfileexistbypath flag_sdcard= ' +flag_sdcard+ ', Data= ' +data);            if (Flag_sdcard = = 0) {                     if (data = = 0) {                        scscms_alert (Getlang ("SDcard"), Getlang ("sure"));                        //    Alert ( ' Please check if your phone's SD card is normal ');                    } else {                         if (Platform1 = = 1) {         & nbsp;                 // Update for Android, download by creating a download                              Uexdownloadermgr.createdownloader ("14");                         }else if (Platform1 = = 0) {                             //Apple update//                             uexwidget.loadapp ("" , "", UpdateUrl);                        }                    }           }     };   //Get the platform version callback function to determine if the client is the client of that platform (step:2)     uexwidgetone.cbgetplatform = function (Opid, dataType, data) {            //alert (' B ');            //Get System Version information callback function              Platform1 = data;            //alert (platform1 );            console.log (PLATFORM1);             if (data = = 1) {                    //Is android                    Flag_sdcard = 0;                     Uexfilemgr.isfileexistbypath ('/sdcard/');//First determine if there is an SD card, then call checkupdate to update             }else if (data = = 0) {                 //alert ("I am iOS");                // Uexwidget.checkupdate ();            }   };      uexwidgetone.getplatform ();//Get Platform Version (step:1)     }   Note: Appcan was unstable before, but the current version is still very stable .。 Thank Appcan for our technology support, currently our app faster than thousands of people using upgrade features more stable.



About the Appcan auto-upgrade feature

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.