Once you have released your application you may want to publish updates to it. AIR makes this very easy and there are a couple different ways to ensure a smooth update process for your users. The following steps are recommended for Shibuya developers who wish to include easy update checking in their application.
This coding example shows how to implement simple updating for an AIR application. This is the pertinent area of the sample code:
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="creationCompleteHandler()" xmlns:ns1="com.adobe.shibuya.containers.*"> <mx:Script> <![CDATA[ import air.update.ApplicationUpdaterUI; import com.adobe.shibuya.controllers.LicenseManager; private var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI(); private static var UNIQUE_NUM:String = "AC56EB19-AB91-B76D-3A84-B821BAD8F60D"; private function creationCompleteHandler():void { appUpdater.configurationFile = new File("app:/config/updateConfig.xml"); appUpdater.addEventListener(ErrorEvent.ERROR, onError); appUpdater.initialize(); var licenseManager:LicenseManager = new LicenseManager(this); licenseManager.checkLicense( UNIQUE_NUM, true ); } private function onError( event:ErrorEvent ):void { trace( event.toString() ); } private function checkForUpdates( event:MouseEvent ):void { appUpdater.checkNow(); } private function getVersion():String { // sample code taken from http://help.adobe.com/en_US/AIR/1.5/devappsflex/WS5b3ccc516d4fbf351e63e3d118676a5e5e-7fff.html var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor; var ns:Namespace = appXml.namespace(); var appVersion:String = appXml.ns::version[0]; //// return appVersion; } ]]> </mx:Script> </mx:WindowedApplication>
Things to note: In your application descriptor file, make sure you have the recommended versioning schema, e.g. <major version number>.<minor version number> The script block imports air.update.ApplicationUpdaterUI, and creates an ApplicationUpdaterUI instance, appUpdater.
In the creationComplete handler (the same function used to handle the License Manager) these lines are present:
appUpdater.configurationFile = new File("app:/config/updateConfig.xml"); appUpdater.addEventListener(ErrorEvent.ERROR, onError); appUpdater.initialize();The initialize() call will check for any pending or postponed updates and install them if needed. If the amount of time set by the delay value in the update descriptor file has expired, the update process will begin (checking for server updates). If it has not, the timer is started.
[Optional] You may want to provide a way for users to check for updates manually. This could be done potentially via help menu option. In the optional function that will check for updates call checkNow() on the ApplicationUpdaterUI instance:
private function checkForUpdates( event:MouseEvent ):void { appUpdater.checkNow(); }
Include the client-side update descriptor file into your project. In this example, it is in the folder named ’config’ (this should be under the ’src’ folder of your project hierarchy). It is called updateConfig.xml, however, you may name it anything you like. The contents will define what updater UI elements the end-user will see during the check for updates and updating events. Important: make sure to insert your app id, found in your app descriptor file, into the url value.
<?xml version="1.0" encoding="utf-8"?> <configuration xmlns="http://ns.adobe.com/air/framework/update/configuration/1.0"> <url>http://apprepo.adobe.com/updates/<your.app.id>/update.xml</url> <delay>1</delay> <defaultUI> <dialog name="checkForUpdate" visible="true" /> <dialog name="downloadUpdate" visible="true" /> <dialog name="downloadProgress" visible="true" /> <dialog name="installUpdate" visible="true" /> <dialog name="fileUpdate" visible="true" /> <dialog name="unexpectedError" visible="true" /> </defaultUI> </configuration>
When you have an update to your application to issue, follow these steps (once our ADC site is up):