Extended AIR App Updater
Sep. 2, 2009 4 Comments Posted under: AIR, ActionScript, Flex
I have always used Adobe’s ApplicationUpdater in my AIR apps, either with or without the UI. However every time I do I always find I need the functionality to force the user to update. This is normally due to an important feature or bug fix that I need pushed out to users, or just to make sure those users who never update don’t get too far behind (I recently found my dad had never updated any of his iPhone apps).
Update framework
When using the ApplicationUpdater (without the UI), you can easily force the install of all updates, but this isn’t very user friendly, and not a great experience. Often it’s far too time consuming to write your own UI for the update framework, so ideally I wanted to create a way of supporting required updates whilst using the existing UI as much as possible.
In order to do this I wrote a decorator for the ApplicationUpdaterUI which added the new event RequiredStatusUpdateEvent. This is dispatched when the updateDescriptor file is downloaded and includes the value of a new node called required (which you need to add to your update.xml file):
<?xml version="1.0" encoding="utf-8"?> <update xmlns="http://ns.adobe.com/air/framework/update/description/1.0"> <version>2</version> <url>http://www.pixelbox.net/demos/extendedAppUpdater/ExampleAirApp-2.air</url> <description> Version 2 - Lots of great new features - Required security patch </description> <required>true</required> </update>
The text “true” will translate into a Boolean set to true, anything else will be false.
You can then add a listener for the (along with any default events), to tell your user they have to update to the new required version. This can be as simple as:
private function onUpdate(event:RequiredStatusUpdateEvent):void
{
if (event.required && event.available)
// Required update available
else
// There isn't a required update, so leave it up to the ApplicationUpdaterUI
}From a UX point of view this works rather well. You can choose how your application responds to a required update, and don’t need to force the install in the background and restart the app. I like to change the state of the app, as well as letting the ApplicationUpdaterUI window open. If the user upgrades through the default UI, great, if not they will be presented with a new app state, telling them there is a required update, perhaps even why it’s important. You may even want to let them do some things but not others (such as letting them save their work, or finishing their current workflow). Either way it gives your app the choice of how it wants to behave.
I have created a little example app (with view source enabled) that uses the this code, as well as a .swc and the example app as a project.
- Example AIR Application
- Extended Updater swc file
- Example Air App project
- Example update descriptor XML file
If you install the above air file, you will be able to check for updates and receive a required update. When this happens the app’s main function is disabled and a message displayed telling the user to upgrade.
Please let me know if you have any questions, or would like to add to this little framework, good luck. If you want to create your own without using the default UI check out this article on Black Pepper
This entry was posted on Wednesday, September 2nd, 2009 at 6:13 pm and is filed under AIR, ActionScript, Flex. You can leave a comment and follow any responses to this entry through the RSS 2.0 feed.
Aha, so this is an extension to the ApplicationUpdater which you can use to change the appearance of the parent application, depending on whether the upgrade is required?
Yeah that’s more or less it. So rather than create your own Update UI from scratch, you can use the default one, and just disable the app if they don’t install a required update.
Have a play with the example AIR app if your not sure :)
Thanks for this, was just about to implement similar functionality for an air app I’m building.
No problem Karl,
If you find anything is missing then I could put it on google code and you could update it to suite your needs :)