7 Replies Latest reply on Aug 5, 2010 3:39 PM by lisachao

    air.swf getApplicationVersion() not calling back

    triq200
      I am trying to use air.swf from http://airdownload.adobe.com/air/browserapi per the Adobe documentation to detect if an air application is already installed. I'm using getApplicationVersion but the callback function is never called. launchApplication() and installApplication() work fine.
      The code looks like this:

      _air.getApplicationVersion(appID, pubID, versionDetectCallback);
      function versionDetectCallback(version:String):void { do stuff }

      VersionDetectCallback() is never called. I de-compiled the air.swf and ran the code directly to try and figure out what's failing. But I get the same result. I can see the timer on the LocalConnection endpoint timing out after 5 seconds. I just can't figure out why the appinstaller is not calling back. The actual call (taken from the decompiled swf) looks like this:

      airappinstaller = new ProductManager("airappinstaller");
      var launchArgs:Array;
      launchArgs = ["-isinstalled", appID, pubID, "adobe.com" + ":" + lcName, "onApplicationVersion"];
      airappinstaller.launch(launchArgs.join(" "));

      where onApplicationVersion is the endpoint callback function and lcName is the LocalConnection name.

      It doesn't matter if I make the call from the Loader Init event or in a button click the callback function is never called. I am using Flash CS3.


        • 1. Re: air.swf getApplicationVersion() not calling back
          adudas Level 1
          I had the same problem. Double check your appID's and pubID's match up. In my air configuration, the id's were correct and were tracing out correct but when I actually opened up the air app to check them, they were different. Open up your air app to make sure.
          • 2. Re: air.swf getApplicationVersion() not calling back
            triq200 Level 1
            Thanks. I checked the appid and pubid and they seem to be correct. I looked in the META-INF\AIR folder for the installed app to double-check. Also launchApplication works correctly with these ids so I assume that means they must be ok at some level.
            • 3. Re: air.swf getApplicationVersion() not calling back
              moutfeh5


              Hi,

               

              I would like to ask if you overcome this problem, and how, coz i am facing it too

               

              Thanks

              • 4. Re: air.swf getApplicationVersion() not calling back
                bobbybeag

                Yes I am having the same problem - and its doing my scragbox in.  I have followed the tutorials but same problem for me - Has anyone found a solution? 

                • 5. Re: air.swf getApplicationVersion() not calling back
                  lisachao Adobe Employee

                  Are you on windows by any chance?  Can you try the following work arounds:

                   

                  1) Set up a timer (10 sec or so) and take action if the timer fires without the callback having gotten called.

                  2) Getting a new AIR.SWF object for each call to getApplicationVersion()


                  • 6. Re: air.swf getApplicationVersion() not calling back
                    bobbybeag Level 1

                    Hi Lisa,

                     

                    I am on windows yes,  and I seem to have got it working.  I found this problem to be very perculiar as there were many things my badge didnt like - such as a case statement instead of a load if if's.   anyway my solution is below,  although I must say, that now nothing happens if the user doesnt have air installed!  If they have Air installed but not my application, it will install my app but the need air installed first and that is not ideal!

                     

                    Maybe implementing your timer solution may help this?  Thanks for taking an interest!

                     

                    private var _toDo:String;

                     

                    private function onInit(e:Event):void
                    {
                                _air = e.target.content;
                                try
                                {
                                  _air.getApplicationVersion(_applicationID, _publisherID, versionDetectCallback);
                                }
                                catch (e:Error)
                                {
                                  trace('air not installed');
                                   root.statusMessage.text = 'Adobe Air not installed'
                                   _toDo = new String("installAir")
                                }
                    }

                     

                    private function versionDetectCallback(version:String):void
                    {
                                if (version == null)
                                {
                                   trace('app not installed');
                                   root.statusMessage.text = 'Coach Player not installed'
                                   _toDo = new String("installApp")
                                }
                                else
                                {
                                   trace('app version ' + version + ' installed');
                                   root.statusMessage.text = 'Application version ' + version + ' installed'
                                   _toDo = new String("launchApp")
                                }

                    }

                     

                    private function onButtonClicked(e:Event):void

                    {
                       root.statusMessage.htmlText = "onButtonClicked"
                       if(_toDo == "installAir"){installAir()}
                       if(_toDo == "installApp"){installApp()}
                       if(_toDo == "launchApp"){launchApp()}

                      }


                      protected function installAir():void
                      {
                       root.statusMessage.text = 'Installing Adobe Air';
                       _air.installApplication( _appURL, _airVersion, _arguments );
                       //root.statusMessage.text = _appURL+" | "+ _airVersion+" | "+ _arguments
                      }

                     

                      protected function installApp():void
                      {
                       root.statusMessage.text = 'Installing Coach Player';
                       _air.installApplication( _appURL, _airVersion, _arguments );
                       //root.statusMessage.text = _appURL+" | "+ _airVersion+" | "+ _arguments
                      }


                      protected function launchApp():void
                      {
                       root.statusMessage.text = 'Launching Coach Player';
                       _air.launchApplication(_applicationID, _publisherID, _arguments);
                       //root.statusMessage.text =  _applicationID+" | "+ _publisherID+" | "+ _arguments;
                       //root.statusMessage.text = _arguments;
                      }
                     

                    • 7. Re: air.swf getApplicationVersion() not calling back
                      lisachao Adobe Employee

                      Yes, please try the timer and let me know if that works or not.

                       

                      Also, try this for function onInit :

                       

                      private function onInit(e:Event):void {
                          _air = e.target.content;
                          switch (_air.getStatus()) {
                              case "available" :
                                      root.statusMessage.htmlText = "<p align='center'><font color='#"
                                              + _messageColor + "'>In order to run this application, "
                                              + "this installer will also set up Adobe® AIR™.</font></p>";     
                                  _toDo = new String("installAir");
                                    
                          }
                      }