DotnetDude
DotnetDude

Reputation: 11807

Versioning approaches for a HTML5 Mobile app

I am creating a mobile appl using Phonegap, HTML5 and web services. This will be targetting both the Android and the iOS (Ipad and Iphone) devices.

What approach do I need to use for versioning the mobile app and the services? If both the app and the web service starts with version 1.0,

  1. Should I have new versions for both of them at the same time?
  2. If the user ignores a new version and doesn't do the update, do I need to maintain older versions of the service?
  3. If yes for (2), how long would I keep the older versions around?
  4. Is there a way to force the user to do the app upgrade?

Any help is appreciated.

Upvotes: 2

Views: 387

Answers (4)

caiocpricci2
caiocpricci2

Reputation: 7798

1) Should I have new versions for both of them at the same time?

No. Each platform should have it's own version number. What if you have a bug happening only on iOS? Will you bump the Android version too? Doesn't sound good. What I find very useful is keeping a simple dated chart with bullet point changes for each version and each platform.

2) If the user ignores a new version and doesn't do the update, do I need to maintain older versions of the service?

You should plan ahead and avoid "breaking changes" so if the user has an older version it will still work. Sometimes you can't avoid it and you need to deprecate things, but you should keep them around.

3) If yes for (2), how long would I keep the older versions around?

If you absolutely have a breaking change, keep the old version around until you are sure most of your users won't suffer when you remove it. Warn them over and over again that the version they are using will stop working soon and they should do the upgrade.

4) Is there a way to force the user to do the app upgrade?

Send the client version number in your api calls, and based on that number you can do whatever you like. You can send back a message telling the users they can't go further unless they update for example.

Upvotes: 1

user1076821
user1076821

Reputation:

You can simply create an HTML5 Application Cache.

With an Application Cache, your app will also be accessible offline as well, as well as the ability to create new updates easily and to force users to update (if they're online).

You should keep the version number consistent across both platforms if you use this method. You will be able to force update through this method, so the need to maintain users on old versions goes away. To answer #3, I think that is up to you after you analyze your user base and come to a conclusion.

In the App Cache, all assets must load or it will fail, so be mindful of what you declare in your cache manifest. I recommend listing static assets only.

Learn more about HTML Application Cache: http://www.html5rocks.com/en/tutorials/appcache/beginner/

This solution is on the front end, so you will have to use JavaScript to manage the versions and application cache.

To detect new versions of an application in JS the code block below will detect when a user loads your application:

window.addEventListener('load', function(e) {//NOTICE this only fires on page load, you can put this in a setInterval, if you'd like
  if (window.applicationCache) {  //Application cache is supported
    window.applicationCache.addEventListener('updateready', function(e) {  
        //Listening for an updated cache 
        if (window.applicationCache.status == window.applicationCache.UPDATEREADY)    {  
          window.applicationCache.swapCache();    
          if (confirm('A new version of this site is available. Load it?')) { 
            //If user accepts new version of site, it will reload the site.  
            window.location.reload();   
          }
        } else {    
          return;    
        }    
    }, false);    
  }    
}, false);

It will simply ask if the user would like the load the new version of the site, however since you want to force update a user, you can modify this to look like:

window.addEventListener('load', function(e) {//NOTICE this only fires on page load, you can put this in a setInterval, if you'd like
  if (window.applicationCache) {  //Application cache is supported
    window.applicationCache.addEventListener('updateready', function(e) {  
        //Listening for an updated cache 
        if (window.applicationCache.status == window.applicationCache.UPDATEREADY)    {  
          window.applicationCache.swapCache();    

            //Force update a user when a new version becomes available
            window.location.reload();   

    }, false);    
  }    
}, false);

Any changes in your application cache manifest will create a new version of the application, for instance if your manifest looks like:

CACHE MANIFEST
#Version 1.0

game.html
assets/css/style.css

NETWORK
*

...and you change it to:

CACHE MANIFEST
#Version 1.0
#I love cupcakes and candy

game.html
assets/css/style.css

NETWORK
*

You will automatically create a new version of your application.

As far as I can tell, this will be a good solution to solving your problem, however I do hear that there is a little more work to do to get it working on Android (link below).

PhoneGap Application Cache tutorial: http://tmkmobile.wordpress.com/2012/03/04/html5-offline-solution/

Upvotes: 0

Vlad Stirbu
Vlad Stirbu

Reputation: 1792

1) The server and the application versions do not have to be the same. In fact they should evolve independently. Semver gives a good guideline on when to bump the version number.

2, 3). Ideally you should design the service in such a way that it handles gracefully older versions. But if you really have to deprecate some functionality, you are the only one that can decide when to do so.

4) You may reject an older client to interact with your server, but provide a meaningful error message to the client that instructs the user to upgrade.

Upvotes: 3

Adam Ware
Adam Ware

Reputation: 1202

Not really a way to force a user to upgrade other then including a JS file that checks something on your own server to see if an update is available (like checking a manifest file of sometype)

My personal experience is to keep as much of the code the same across both platforms so you don't have to code for both. And you'll never get away from having legacy versions in the wild. But I generally stop supporting older versions after 12 months.

Upvotes: 0

Related Questions