menu

Blog

  • Update checks and new version installation for Adobe AIR applications

    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.

    Updating Your 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):

    1. Change the version in your application descriptor file, e.g. 1.1 if your initial release was 1.0. Note: do not change the application id!
    2. Export your application to an AIR file and name it MyAwesomeApp1.1
    3. Log-in to the Adobe Developer Connection (ADC) and on the home page choose to ’Edit’ the given application
    4. Click on ’UPLOAD A NEW VERSION’ and follow the directions
    5. This new version will be marked as ’new’. Once you have tested it, change it’s status to ’Submission Complete’ and users will be able to download the latest version after review by Adobe. Note that you cannot test updating in the AIR Debug Launcher (ADL), you must use the AIR file directly.
    Your server-side descriptor file will be automatically updated to point to this latest version once you mark it as ’Available for download’. If you decide later to remove the update for some reason, the 1.0 version of your application will be current and the server-side descriptor file updated automatically.