Quick Tip: Checking The Version Of An Installed AIR Application

Here is a quick tip how to check the version of your installed AIR application from an application running in flash player. In order to make your AIR application (system) be able to respond to the requests for installed version correctly you need to define allowBrowserInvocation within your AIR descriptor file (app.xml). If you don’t do this, you won’t be able to query version information on your application:

<allowBrowserInvocation>true</allowBrowserInvocation>

Now your AIR application will respond correctly with its installed version. With this setting on, the installed AIR application can be launched via the browser invocation feature (by the user clicking a link in a page in a web browser). Be sure to consider security implications.

Now, to get version info from any application running in flash player (or AIR) you simply call getApplicationVersion() method on air.swf file located on adobe domain.

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.load(new URLRequest("http://airdownload.adobe.com/air/browserapi/air.swf"));

function onComplete(event:Event):void 
{
    // applicationID - <id>sk.yoz.whatever</id> defined in app.xml
    // publisherID - WindowedApplication().nativeApplication.publisherID
    Object(loader.content).getApplicationVersion(applicationID, publisherID, appVersionCallback);
}

function appVersionCallback(version:String):void
{
    if (version == null)
        // application is not installed
    else
        // installed, compare variable version with some desired
}

Please consider this code as extract from AIRInstallBadge package downloaded from Adobe. The badge also uses more advanced features, make sure to read the article or see the source code.

Where to go from here:

Leave a comment

Please be polite and on topic. Your e-mail will never be published.