Autoupdating AIR
Update: you can access your complete application descriptor xml in beta2 now.
var VERSION:String = Shell.shell.applicationDescriptor.@version;
No more need to keep version twice.
When i first got my hands on Apollo alpha, i did a quick check on it’s original features. My first stop was on “autoupdate”.
After downloading and inspecting what was on the web, i decided that i wanted a “complete” solution:
- publish by simply dropping an AIR archive into my repository
- be able to up-/downgrade and update-to-latest
- have a simple control to support the user
Playing around with the demo code, i found some issues:
- You can access application.appID (in <app>-app.xml) as Shell.shell.id, but there is no way to access application.version . Therefore you have to keep two version-infos in sync (which is bad).
- I did not want to rely on file-naming, so i had to get the version info out of the archive. Which isn’t that hard as .air files are simply zipped directory/file-structures.
The Component
All of this led to a simple client-server-architecture. The server collects version info on the files laying around. The client part parses this information and requests a single file for download (and update).
On the server-side i use minixml and pclzip to build a PHP component that
- scans a directory for all .air files
- unzips “META-INF/AIR/application.xml” on-the-fly and
- parses application.appID, application.version and the .air file-path into a list.
The collected info is then summarized by appID, sorted by version and sent to the client as an xml.
After parsing the xml, the client-code searches the list of newer versions (or all if forceUpdate is true) and hands it over to the update-alert for display. If the user selects an entry and clicks ok, the archive is downloaded to a temporary file and installed.
The standard (prompt on update available) way can be integrated with as little code as this:
...
aUpd = new AutoUpdater();
aUpd.addEventListener( Event.COMPLETE, handleUpdate);
aUpd.load( null);
}
private function handleUpdate( evt:Event):void {
var vlist:Array = aUpd.findVersions( Shell.shell.id, VERSION, forceUpdate);
if ( vlist != null) aUpd.show( this, vlist, VERSION);
}
For convenience there is a updateToLatest( appName:String, version:String) function which does not require user interaction.
I use the same mechanism to build a html-page listing all applications with their most recent version (including all prevoius versions). You can do a manual install/update from there.
Only drawback is the mentioned need to keep two version-strings in sync.


Leave a Reply