Calendar

August 2008
M T W T F S S
« Jul   Sep »
 123
45678910
11121314151617
18192021222324
25262728293031

Tag Cloud

Categories

Archives

Highest Rated

Most Viewed

Recent Posts

Recent Comments


« Flex 4 Skins are Awesome! | Main | Congrats to Open Flex! »

AIR Update Framework

By Rich Tretola | August 1, 2008Print This Post Print This Post
1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5 out of 5)
Loading ... Loading ...
942 views



I have been using the new AIR Update Framework in all of my new AIR applications in place of my UpdateManager that was originally written to handle application updates before the Adobe version was released.

The simplest way integrate this framework into your application is to setup your local configuration file with the checkForUpdate property set to false and all others set to true. This property is not telling the framework to never check for updates, it is simply telling the framework to hide the check for update dialog from the user so they will only see a dialog if an update actually exists.

In the sample below notice that the only other property that is necessary is the address of the remote update file. This local configuration file will ship with your application.

  1. <?xml version="1.0" encoding="utf-8"?>
  2.  <configuration xmlns="http://ns.adobe.com/air/framework/update/configuration/1.0" >
  3.    <url>http://www.mydomain.com/AIR/Test/update.xml</url>
  4.    <delay>1</delay>
  5.    <defaultUI>
  6.        <dialog name="checkForUpdate" visible="false" />
  7.        <dialog name="downloadUpdate" visible="true" />
  8.        <dialog name="downloadProgress" visible="true" />
  9.        <dialog name="installUpdate" visible="true" />
  10.    </defaultUI>
  11. </configuration>

The remote file contains only a few properties. Notice the sample below where I have set a version property, url to the newest application file, and a small description which will display in the release notes section of the updater dialog.

  1. <update>
  2. <version>.2</version>
  3. <url>
  4. http://www.mydomain.com/AIR/Test/myApp.air
  5. </url>
  6. <description>
  7. Added new image rotation feature.
  8. </description>
  9. </update>

Finally, within the application do the following:

Create an instance of the updater on line 8

After the application completes, I set the path to the local configuration file within the init function.

Next, I add an eventListener to listen for when the updater is initialized.

Within the eventListener function, I then call the checkNow() function.

Since, we hid the first dialog, the updater will now check for the update and only show the user a dialog when an update exists (see image below). If so, it will then walk them through the rest of the update process.

Here is the full application code:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
  3.     applicationComplete="init()">
  4.     <mx:Script>
  5.         <![CDATA[
  6.             import air.update.events.UpdateEvent;
  7.             import air.update.ApplicationUpdaterUI;
  8.             private var updater:ApplicationUpdaterUI = new ApplicationUpdaterUI();
  9.  
  10.             private function init():void{
  11.                 updater.configurationFile = new File("app:/config/updaterConfig.xml");
  12.                 updater.addEventListener(UpdateEvent.INITIALIZED, updaterInitialized);
  13.                 updater.initialize();
  14.             }
  15.  
  16.             private function updaterInitialized(event:UpdateEvent):void{
  17.                 updater.checkNow();
  18.             }
  19.         ]]>
  20.     </mx:Script>
  21. </mx:WindowedApplication>

air updater

Share/Save/Bookmark

Topics: Adobe AIR |

10 Responses to “AIR Update Framework”

  1. Marcus Baffa Says:
    August 4th, 2008 at 9:57 am

    I have implemented the AIR Updater in my First AIR application. When the version changes the Updater show its messagebox correctly but I receive the following message:
    There was an error downloading the update. Error# 16820

    I am sure that the remote update.xml and the application-app.xml have the same new version number

    Can you help me !!!

  2. everythingflex Says:
    August 4th, 2008 at 11:27 am

    Did you check to make sure the path to your new AIR file set within the url property of the remote update.xml file is accurate?

  3. Marcus Baffa Says:
    August 5th, 2008 at 7:27 pm

    Yes it it. Both the update.xml and the application-app.xml have tha same new version and the URL is OK.
    The message box appears to download the new version so it is looking in the right place.

  4. Rich Tretola Says:
    August 5th, 2008 at 8:07 pm

    So, it downloads but can’t update?

  5. Sean Says:
    August 25th, 2008 at 7:24 pm

    Yes, we tried this as well …
    Seems to be a bug …
    Any fixes ?
    Regards,

    Sean.

    Free Digital Signage powered by Adobe AIR
    http://www.MediaSignage.com

    Rich Tretola Reply:

    I have not been able to reproduce this issue.

  6. Chris Says:
    August 29th, 2008 at 12:17 pm

    I have run into the same issue. Versions are the same URL is fine. Also it works fine when run on my localhost but once I change the URL’s to my live website it throws the error…”There was an error downloading the update. Error# 16820″. It detects the correct version to be updated, the correct AIR file is in the correct directory.

    I am wondering seeing as this only happens when I publish it live if it has something to do with my hosting company. I use Host My Site.com and they are usually up on things. I tried changing file permissions on the folder containing the app but that did not work either. I have a feeling it might have something to do with it being on a shared hosting server.

    Anyone have any thought or suggestions?

    Chris Reply:

    BTW… When my app checks for the update it sees the “Installed Version” and the “Update Version” in the “Update Available” window, but never downloads the app like Sean is describing above. As soon as I click on the “Download Now” button it throws the “Download Failed” error message.

  7. funkyboy Says:
    September 3rd, 2008 at 8:52 am

    I think the application ID has to be the same, and also the certificate.

  8. JabbyPanda Says:
    September 16th, 2008 at 5:02 am

    2Chris: Make sure, that inside “update.xml” you point to correct download path of your AIR application.

    I’ve also had received Error# 16820 before, because the download path of AIR application inside “update.xml” file was incorrect.

Comments