facebook

Native App Updates

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #346504 Reply

    herb200mph
    Participant

    We have the app deployed for client review on identified devices.

    Client’s have Version 1 on their devices.

    We make changes to the app and upload to server location.

    Is there any way, when client opens the Version 1 app, that it automatically uploads Version 2?

    We would like the app to self-update when opened.

    Any scripting or code available to do that?

    #346509 Reply

    Hi Herb,

    Yes, custom update detection can be built into an app with a little bit of custom coding. For example set a version identifier your app. Then on startup the app can query your server for the current version of the app and a download URL. The compares the current app version to that of your app. If there is a newer version then notify or consult the user. Then open the installer URL using a GotoURL in a system browser.

    #346546 Reply

    herb200mph
    Participant

    Thanks for the guidance.

    The next challenge is: where do we get the custom code or a snippet of code to pull off the version checking to cause an updated app to download.

    #346553 Reply

    Brandon
    Member

    You can use a simple text file with an ajax call to a server to check the current version;
    something like:

     $.ajax({
                url: "yourserver.com/currentversion.txt",
                async: false,
                success: function (data){
                    if (myVersion < data){alert('you need to update'};
                    //myVersion can easily be stored in local storage or any other way you would like
                }
            });
    #346558 Reply

    herb200mph
    Participant

    Wow! Thanks Cincy.

    Can you tell us where and how to implement and include that script into an app.

    You can write me direct at: mailto:herb200mph@gmail.com

    #346564 Reply

    Brandon
    Member

    What kind of data are you trying to update?

    #346567 Reply

    herb200mph
    Participant

    The app is 365 screens of static data = a reference document.

    If we make changes to the document/screens, and the app user opens it, we want the app to display an update button or something along those lines, or just update automatically in the background.

    We could put a button on the opening screen that says: Download an Update, but client would rather have it done automatically.

    Need anything else?

    #346569 Reply

    Brandon
    Member

    Is the data mainly text? Images? Screen layout? How often will the app need to be updated?
    Some are a lot more difficult to update than others. Anything more that text you will probably be better off doing a update in the store, in iOS 7 you can set the apps to auto update when they become available, thats how mine is, its really nice.

    The main problem is that you will need to store the information somewhere to pull from to do the updates. You can use files and images but you will need the PhoneGap API to write new files (I have had mixed results with this). The other idea is to use local storage, but with a high amount of data Im not sure how feasible this would be.

    #346575 Reply

    herb200mph
    Participant

    End product will be apps self-hosted under an enterprise license.

    Apps will be updated infrequently.

    Pages consist of text and images and “htm” pages with links to PDF files.

    We are self-hosting now and client is reviewing via ad hoc UDID permissions.

    Apps WILL NEVER be in the AppStore as the content is not intended for public use. Internal documents only.

    There are 4 contact phone/email screens in the app, which are likely the ones that will be updated most frequently.

    Goal:

    1) When app is opened and there has been a change, it updates itself or asks for an “install” to be executed.
    or
    2) App simply updates itself when opened.
    or
    3) We put an “Update Now” link on the pages that have changed, and when clicked, app downloads itself.

    #346578 Reply

    Brandon
    Member

    I would just do a simple version in local storage, then check this against a text file, then if it needs to be updated ask the user to update and show them the url.

    Version check (off the top of my head, untested):

    
    if (localStorage.getItem('myVersion') == null)//first run
    {localStorage.setItem('myVersion','1');}
    else
    {
    myVersion = localStorage.getItem('myVersion');
    $.ajax({
                url: "yourserver.com/currentversion.txt",
                async: false,
                success: function (data){
                    if (myVersion < data){alert('you need to update');phoneui.gotoUrl(updateFileUrl);};
                }
            });
    }
    
    #346580 Reply

    herb200mph
    Participant

    Cincy:

    Not being all that dumb, but not being programmers or code folks, we are not understanding the physical implementation of the code you sent.

    What sort of file would that code go into and where is the reference to local storage … the app server … the app itself???

    Perhaps some more guidance is needed on our end on how to specifically implement the updater actions.

    #346586 Reply

    Brandon
    Member

    The code could go anywhere you want to check for the update, be it a button or even in the document load event in the xxx_custom.js file.

    The yourserver.com would be any web host you have that you can host a file that you can update with the latest version of the app, for ease of use I would use a single number in the text file.

    In the new version you would of course use something like if localstorage == 2 or whatever the new version is.

    I would start small if you are new to implementing something like this. First implement the version checking in local storage.
    Like this, it will check for the localstorage item, if its not there it will add it, if it is there it will alert you to the current version number.

    if (localStorage.getItem('myVersion') == null)//first run
    {localStorage.setItem('myVersion','1');}
    else
    {alert(localStorage.getItem('myVersion');}
    #346642 Reply

    rick.gommers
    Member

    Wow this is cool Cincy! A while back I was searching everywhere for simple example like this.. Way to go!


    @herb200mph
    , if you are not sure where to put this code, put it in the custom.js from your startup screen so it is always loaded.

    Then, attach an onClick handler to an update button so you can verify it’s working.

    The onclick handler can be as simple as calling your function: checkUpdates()

    Then, put Cincy’s code in a checkUpdates() function:

    function checkUpdates() {
        if (localStorage.getItem('myVersion') == null)//first run
        {localStorage.setItem('myVersion','1');}
        else
        {
        myVersion = localStorage.getItem('myVersion');
        $.ajax({
                    url: "yourserver.com/currentversion.txt",
                    async: false,
                    success: function (data){
                        if (myVersion < data){alert('you need to update');phoneui.gotoUrl(updateFileUrl);};
                    }
                });
        }
    }
    #346802 Reply

    RichardOne
    Member

    Hi Cindy,

    Where/how do I put the update check code in my app?

    Is there a tutorial for this please?

    #346848 Reply

    Brandon
    Member

    You can place the main code in your custom.js file, and call the update from a button or any other time you want.
    There is not currently a tutorial, but I may put one together as it seems a lot of people are interested in it.

Viewing 15 posts - 1 through 15 (of 22 total)
Reply To: Native App Updates

You must be logged in to post in the forum log in