Wiki

Clone wiki

dsair / AppUpdateManager

HOWTO: AppUpdateManager: Perform easy automatic app updating

Introduction

Air comes with a feature that allows you to update the app automatically meaning it's relatively trivial to make sure your users always have the latest version. The AppUpdateManager encapsulates all of that.

Details

Check out the TestAppUpdateManager.as file for the full details

As with all examples, you need to init the framework before doing anything:

#!actionscript

DSAir.init( this ); // "this" is your Document class

Checking for updates

Simply call

#!actionscript

AppUpdateManager.instance.checkForUpdate( "[PATH_TO_UPDATE_XML_FILE]/update.xml" );

and the AppUpdateManager will take care of the rest for you. If there's an error in the process, you'll get error dialogs explaining what went wrong.

If there's no update available, by default an alert is shown that says "You're up-to-date". If you want to suppress that, set the showNoUpdateAvailableAlert property to false.

After updating

Calling

#!actionscript

AppUpdateManager.instance.isFirstRun

will return true or false if this is the first time the app has run after an update. This lets you do any migration work if you need to.

Generating the version.xml file

The version.xml file needs to follow a specific format for it to be valid. Calling

#!actionscript

AppUpdateManager.instance.generateUpdateXML( "[PATH_TO_APP].air", "The notes for this version", "1.0.2", false );

will generate and open a save dialog for you. The third parameter is the version of the app that people will update to. It should follow the form {0..999}.{0..999}.{0..999}.

The final parameter is whether you're compiling with AIR2.5 or not. The xml changed slightly after this version.

Updated