2 Replies Latest reply on Jan 19, 2011 2:48 AM by rkfup

    Proper use of installFromAirFile() function in ApplicationUpdater

    mindbaneprogramer

      We have an AIR client app that is composed of several sub programs. We want to be able to push out automatic updates to all the programs. We have a system set up so that each program can download its own update. For reliability purposes we would like to instead download one large AIR package and have the sub programs install themselves from AIR packages on the local drive.

       

      According to the documentationn found here:

      http://help.adobe.com/en_US/AIR/1.5/jslr/air/update/ApplicationUpdater.html#installFromAIR File%28%29

       

      You are supposed to be able to install from a locally stored AIR file but I can't seem to get it to work within a test program. Can anyone give me a hand working out the proper syntax?

        • 1. Re: Proper use of installFromAirFile() function in ApplicationUpdater
          mindbaneprogramer Level 1

          So I managed to figure it out, sorta.

           

          I didn't end up using the installFromAirFile() function at all. I was able to use the applicationUpdater normally by just pointing it to a local update.xml which pointed it to a local update.air file. Here is what I did.

           

          private function Update():void
          {
               var update:File = File.applicationDirectory;
               update =  update.resolvePath("Update.updaterTest.xml");
               
               var updater:ApplicationUpdater = new ApplicationUpdater();
               updater.updateURL = update.url;
               
               updater.addEventListener(UpdateEvent.INITIALIZED, onUpdateInit);
               
               updater.addEventListener(DownloadErrorEvent.DOWNLOAD_ERROR, onErrorEvent);
               updater.addEventListener(ErrorEvent.ERROR, onErrorEvent);
               updater.addEventListener(StatusFileUpdateErrorEvent.FILE_UPDATE_ERROR, onErrorEvent);
               updater.addEventListener(StatusUpdateErrorEvent.UPDATE_ERROR, onErrorEvent);
               
               updater.initialize();
          }
          
          private function onUpdateInit(event:UpdateEvent):void
          {
               event.currentTarget.checkNow();
          }
          
          private function onErrorEvent(event:ErrorEvent):void
          {
               Alert.show(event.toString());
          }

           

          With the update.xml formatted like this.

           

          <?xml version="1.0" encoding="utf-8"?>
          <update xmlns="http://ns.adobe.com/air/framework/update/description/1.0">
            <version>1.1</version>
            <url>app:/updaterTest.air</url>
            <description>
              <![CDATA[
                Update
              ]]>
            </description>
          </update>
          

           

          This seems to work like a charm.

          • 2. Re: Proper use of installFromAirFile() function in ApplicationUpdater
            rkfup

            Hello, i can see your question is marked as answered. But due to your own rating of a "kind of" solve i wanted to add a way i made the update via InstallFromAIRFile. The important thing is that you have to call the updater.initialize in both cases. Before doing so you cant use the InstallFromAIRFile-Function.

             

            In the INITIALIZED Event-Handler you must not call updater.checkNow() in those cases where you want to install a local update but call the updater.installFromAIRFile(file) instead. The downside is that it does not show the confirmation dialog for starting the installation but just does so. But because the user has explicitly started the update by the doublcklick the not showing of the confirmation dialog is not a real problem to me. The default ui for the progress of the updating and possible errors is shown anyway.

             

            Addo: For People which want to use the same logic for updates from the internet as local updates you can use the appInvoke Event of the Native Application to see if a local update was started by the user (by doubleclicking the air installer of a newer version of the app). If you have configured your application.xml to not use the default update ui your application will be started always even in update cases. And will get started with the path to the updateFile passed as an argument. So in those cases you can easily decide to use the installFromAirFile-Function, and if no argument is present you can simply go for updater.checkNow() to use the default Update-UI anyway like you have configured it for your updater. This solved the problem for me.