Created
February 7, 2016 06:32
-
-
Save velara3/73d9e339ac09aa46bc9a to your computer and use it in GitHub Desktop.
How to use AIR badge installer and updater for your AIR apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to use AIR badge installer and updater for your AIR apps | |
Using this class in your application: | |
https://github.com/monkeypunch3/flexcapacitor/blob/master/MainLibrary/src/com/flexcapacitor/effects/application/UpdateApplication.as | |
Add the FCLibrary.swc to your project and then add this code to your main application file: | |
<fx:Declarations> | |
<handlers:EventHandler eventName="initialize"> | |
<local:UpdateApplication id="updateApplication" | |
traceEvents="false" | |
updateURL="http://www.example.com/updates/UpdateDescriptor.xml" | |
error="updateApplication_errorHandler(event)" | |
firstRun="trace('first time running')" | |
updateAvailable="trace('Current version: ' + updateApplication.currentVersion + '. Remote version: ' + updateApplication.remoteVersion)" | |
> | |
</local:UpdateApplication> | |
</handlers:EventHandler> | |
</fx:Declarations> | |
Note: You can also call updateApplication.play() on the application initialize event. | |
You can now follow the notes here or described in the UpdateApplication.as AS documentation. | |
I recommend reading the documentation at UpdateApplication.as and then continue here. | |
I use the next section every time I need to make a new update: | |
*********************************************** | |
How to update the application online | |
*********************************************** | |
update the version number 1.5,1.6,1.7, etc in the application descriptor | |
create a new air build | |
*optionally create a dmg build, compress to zip file with readme instructions | |
login to your server and upload the AIR application file to a /releases directory | |
upload and open the /releases/update-descriptor.xml on the server (file shown below) | |
update the version number in the update-descriptor.xml | |
update the file name in the update-descriptor.xml | |
upload and open the releases/badge_installer.html page (file shown below) | |
update the file name in the badge_installer.html at top of page | |
update the file name in the badge_installer.html at bottom of page | |
embed badge installer using an iframe in your downloads page (file shown below) | |
*********************************************** | |
UpdateDescriptor.xml: | |
*********************************************** | |
<?xml version="1.0" encoding="utf-8"?> | |
<update xmlns="http://ns.adobe.com/air/framework/update/description/2.5"> | |
<version>2.1.0</version> | |
<url>http://example.com/updates/Example_2.1.0.air</url> | |
<description><![CDATA[List the changes in this version here]]> | |
</description> | |
</update> | |
*********************************************** | |
BADGE INSTALLER THAT SUPPORTS HTTPS: | |
*********************************************** | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> | |
<title>Adobe AIR Application Installer Page</title> | |
<style type="text/css"> | |
<!-- | |
#AIRDownloadMessageTable { | |
width: 217px; | |
height: 180px; | |
border: 1px solid #999; | |
font-family: Verdana, Arial, Helvetica, sans-serif; | |
font-size: 14px; | |
} | |
#AIRDownloadMessageRuntime { | |
font-size: 12px; | |
color: #333; | |
} | |
--> | |
</style> | |
<script language="JavaScript" type="text/javascript"> | |
<!-- | |
// ----------------------------------------------------------------------------- | |
// Globals | |
// Major version of Flash required | |
var requiredMajorVersion = 9; | |
// Minor version of Flash required | |
var requiredMinorVersion = 0; | |
// Minor version of Flash required | |
var requiredRevision = 115; // This is Flash Player 9 Update 3 | |
// ----------------------------------------------------------------------------- | |
// --> | |
</script> | |
</head> | |
<body bgcolor="#ffffff"> | |
<script src="AC_RunActiveContent.js" type="text/javascript"></script> | |
<script language="JavaScript" type="text/javascript"> | |
<!-- | |
// Set the application settings for your AIR app here | |
// There are two places to set your application info | |
// Here and at the bottom of the page (for when JavaScript is not enabled) | |
var applicationName = "Example"; | |
var secure = true; | |
var protocol = secure ? "https://" : "http://"; | |
var applicationURL = protocol + "www.example.com/updates/releases/Example_2.1.0.air"; | |
var airVersion = "2.5"; // badge installer version works fine at 2.5 even for newer versions of air | |
var badgeImage = "badge_icon.png"; | |
var flashvars = 'appname=' + applicationName + '&appurl=' + applicationURL + '&airversion=' + airVersion + '&imageurl=' + badgeImage; | |
// Version check based upon the values entered above in "Globals" | |
var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision); | |
// Check to see if the version meets the requirements for playback | |
if (hasReqestedVersion) { | |
// if we've detected an acceptable version | |
// embed the Flash Content SWF when all tests are passed | |
var pluginsPage = secure ? "https://www.macromedia.com/go/getflashplayer" : "http://www.macromedia.com/go/getflashplayer"; | |
var codebase = secure ? "https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" : "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"; | |
var airWinInstaller = secure ? 'https://airdownload.adobe.com/air/win/download/latest/AdobeAIRInstaller.exe' : 'http://airdownload.adobe.com/air/win/download/latest/AdobeAIRInstaller.exe'; | |
var airMacInstaller = secure ? 'https://airdownload.adobe.com/air/mac/download/latest/AdobeAIR.dmg' : 'http://airdownload.adobe.com/air/mac/download/latest/AdobeAIR.dmg'; | |
var genericAIRInstaller = secure ? 'https://www.adobe.com/go/getair/' : 'http://www.adobe.com/go/getair/'; | |
AC_FL_RunContent( | |
'codebase',codebase, | |
'width','217', | |
'height','180', | |
'id','badge', | |
'align','middle', | |
'src','badge', | |
'quality','high', | |
'bgcolor','#FFFFFF', | |
'name','badge', | |
'allowscriptaccess','always', | |
'pluginspage', pluginsPage, | |
'flashvars',flashvars, | |
'movie','badge' ); //end AC code | |
} else { // Flash Player is too old or we can't detect the plugin | |
document.write('<table id="AIRDownloadMessageTable"><tr><td>Download <a href="'+ applicationURL + '">' + applicationName + '</a> now.<br /><br /><span id="AIRDownloadMessageRuntime">This application requires the <a href="'); | |
var platform = 'unknown'; | |
if (typeof(window.navigator.platform) != undefined) { | |
platform = window.navigator.platform.toLowerCase(); | |
if (platform.indexOf('win') != -1) { | |
platform = 'win'; | |
} | |
else if (platform.indexOf('mac') != -1) { | |
platform = 'mac'; | |
} | |
} | |
if (platform == 'win') { | |
document.write(airWinInstaller); | |
} | |
else if (platform == 'mac') { | |
document.write(airMacInstaller); | |
} | |
else { | |
document.write(genericAIRInstaller); | |
} | |
document.write('">Adobe® AIR™ runtime</a>.</span></td></tr></table>'); | |
} | |
// --> | |
</script> | |
<noscript> | |
<!-- Secure connection --> | |
<table id="AIRDownloadMessageTable"> | |
<tr> | |
<td> | |
Download <a href="https://www.example.com/updates/releases/Example_2.1.0.air">Radiate</a> now.<br /><br /><span id="AIRDownloadMessageRuntime">This application requires Adobe® AIR™ to be installed for <a href="https://airdownload.adobe.com/air/mac/download/latest/AdobeAIR.dmg">Mac OS</a> or <a href="https://airdownload.adobe.com/air/win/download/latest/AdobeAIRInstaller.exe">Windows</a>.</span> | |
</td> | |
</tr> | |
</table> | |
<!-- Normal connection --> | |
<!-- | |
--> | |
</noscript> | |
</body> | |
</html> | |
*********************************************** | |
BADGE INSTALLER EMBED CODE | |
*********************************************** | |
Click on the icon below to install the desktop version of Radiate. | |
<iframe src="https://www.example.com/updates/badge_installer.html" style="width:240px;height:200px"></iframe> | |
If you have Example App installed already, open the program and it will prompt you to upgrade to the new version automatically. | |
You will see an update dialog with further instructions. Note: The update dialog might be hidden behind the main window. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: In each section, replace www.example.com and Example.air with your own domain and application, obviously.