Adding auto update features to your AIR application in 3 easy steps

Most modern desktop applications, browser plugins, OS’s, etc. automatically check for updates periodically, and some of them even handle the update process with a single click so it’s easy to stay current.  When building AIR applications, it’s also important to provide a good auto-update feature.

During the past several weeks, I’ve been managing a project to build an internal AIR application.  I wrote the original requirements document but forgot to include a simple bullet about auto-updating.  A few days ago, I was handed the source code and other assets and quickly realized my oversight.

Thankfully, adding this capability is dramatically simplified by the Adobe AIR Update Framework that appeared on Adobe labs a few months ago.  There have been several blog articles about the new framework but I thought I would provide a very simple example of the most common update model.

The code below checks to see if a new update is available every time the program is run.  If an update is available, it simply prompts the user to install the new update with the following default UI:

I implemented this using the following 3 steps:

  • I downloaded the AIR update framework from http://labs.adobe.com/wiki/index.php/Adobe_AIR_Update_Framework and copied the included applicationupdater_ui.swc to my project’s lib folder
  • I created a file called update.xml (see tab 3 below) and uploaded it to the server where my .air file lives.  This file identifies the currently available version, the location of the .air file and provides the description shown above as “release notes”.
  • I added code to my existing init() method to initialize the updater.  Once initialized, I triggered an immediate update check via a one-liner event handler.

Every time my application runs, it performs a quick check to see if the version number in the update.xml on my server is different than the version number in my app config file (UpdateSample-app.xml).  If it’s the same, the user sees nothing.  If it is different, the dialog above displays.  The update framework takes care of the dialog, downloading the new air installer and the installation of the new version.  If there is no connection to the server, it silently continues running the existing version of the application.

There are many other options included in the framework, including the ability to have the update check occur every n days.  For more details, see the included documentation and the included samples.

Try out the results

To demonstrate this capability for this blog post, I created a tiny AIR program.  Download UpdateSample.air 1.0 and install it.  It simply displays a small window with the current version number displayed.  When you run it, it will immediately tell you that v1.1 is available and prompt you to install it so you can see the end-user experience.

UPDATE 11/26/2008 - http://gregsramblings.com/2008/11/26/adobe-air-update-framework-for-html-ajax-and-flash-applications/

Source Code

Below is the source code to UpdateSample.air and the update.xml that resides on the server:

P.S. I will be doing a short article about the code viewer SWF used above that I wrote in Flex.  I’ll also explain how I got it to work on the WordPress hosted service, wordpress.com, which doesn’t allow flash in blog post (at least not directly).

~ by gregorywilson on August 16, 2008.

10 Responses to “Adding auto update features to your AIR application in 3 easy steps”

  1. .swc files are nothing more then a nuisance of our industry.
    Why is the dam frame work only for flex and not in raw AS3 source?
    I decompiled the swf embedded in the swc file and seen no dependencies for flex, so why the strong arming to use flex.

    This is bull shit. I have a AIR app that I made with flash and now if I want to get any time of auto update I have to go make my own framework to do so. Thanks a lot adobe.

  2. The docs do neglect to discuss using the framework from flash. However, it does provide examples of building an updater in HTML/JS so that’s another option for you. There are multiple examples of this included on the page.

    The version on labs is a pre-release so it is not complete. Our intent is to provide a flash-friendly way of doing this…it’s mostly a packaging issue.

    It is NOT our intent to ignore flash developers. AIR is a great way for Flash developers to build desktop apps (see http://www.adobe.com/products/air/develop/flash and http://www.adobe.com/devnet/air/flash/ and http://help.adobe.com/en_US/AIR/1.1/devappsflash/). The framework is intended for ALL developers deploying on AIR.

    Thanks,

    Greg

  3. Great job! Thanks for this post.

  4. The compiler ses an error here:

    private function setApplicationVersion():void {
    var appXML:XML = NativeApplication.nativeApplication.applicationDescriptor;
    var ns:Namespace = appXML.namespace();
    ver.text = “Current version is ” + appXML.ns::version;
    }

    **** Access of undefined property ver ****

  5. Paul,

    “ver” is the name of the label at the bottom of the source. Add that label and it’ll work.

    :)

  6. I tried running the code but I cannot get it to work. I do not get any error messages, it just doesn’t work. Is there anything else that needs to be done?

    thanks

  7. Disregard my last post. I found out what I was doing wrong.

  8. [...] also on how to implement steps @ http://gregsramblings.com/2008/08/16/adding-auto-update-features-to-your-air-application-in-3-easy-s... [...]

  9. Does Adobe provide a way to ‘patch’ an Air application or do you need to do a full uninstall and reinstall on each update?

  10. I keep getting the following error when I try to implement the updater code in Gumbo. Any ideas?

    VerifyError: Error #1053: Illegal override of seek in mx.effects.effectClasses.TweenEffectInstance.

Leave a Reply