ちょっと今仕事でairアプリケーションを作っているのですが、airパッケージのアップデートが上手く行かなくてハマっていました。
AIRアプリケーションのアップデート
のヘルプを見ながら作っていたのですが、どうも画像のような「利用可能なアップデート」プロンプトがあがって来てくれない。サーバ側にはversion 0.2があってローカルには0.1がインストールされていて、パス(URL)やversionの差なんかは何度も見直したのですが、アプリを立ち上げても立ち上げてもプロンプトが来ない。。。。
javascriptで書いてる所為なのか?などとあらぬ方向に疑いを持ち始める始末。
と、まぁ画像のように最終的には出来たので良かったのですが、ハマった箇所はどうやらstate.xmlに記述されている内容のようでした。
/Users/<user account>/Library/Preferences/<air app id>/Local Store/#ApplicationUpdater
airパッケージをインストールすると、(Macだと)上記ディレクトリのなかにstate.xmlというファイルができるのですが、テストする時はこのlast Checkのノードにかかれている時間を過去にしてあげないとチェックしに行ってくれないみたい。ふへー。参った。会社でも同じシューティングで動けば良いんだけど。
というわけで、とりあえずソース。
yaruoWorld.html
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<style>
pre.aa{
margin: 1em 0em;
text-align: left;
line-height: 14pt;
font-size: 12pt;
font-family: 'MS PGothic', 'MS Pゴシック', 'mona';
padding: 0.5em;
border: 1px solid #ddd;
background-color: #F6F6F6;
}
</style>
<script src="AIRAliases.js" type="text/javascript"></script>
<script src="applicationUpdater.swf" type="application/x-shockwave-flash"/></script>
<script src="applicationupdater_ui.swf" type="application/x-shockwave-flash"></script>
<script type="text/javascript">
window.onload = function(){
var updater = new air.ApplicationUpdaterUI();
updater.configurationFile = new air.File("app:/updateConfig.xml");
updater.initialize();
}
</script>
</head>
<body>
<pre class="aa">
ノ L____
⌒ \ / \
/ (○) (○)\
/ (__人__) \
| |::::::| |
\ l;;;;;;l /l!| !
/ `ー' \ |i
/ ヽ !l ヽi
( 丶- 、 しE |そ ドンッ!!
`ー、_ノ ∑ l、E ノ <
レY^V^ヽl
</pre>
</body>
</html>
updateConfig.xml
<?xml version="1.0" encoding="utf-8"?> <configuration xmlns="http://ns.adobe.com/air/framework/update/configuration/1.0"> <url>http://mojalog.com/airupdate.xml</url> <delay>1</delay> <defaultUI> <dialog name="checkForUpdate" visible="false" /> <dialog name="downloadUpdate" visible="true" /> <dialog name="downloadProgress" visible="true" /> <dialog name="installUpdate" visible="true" /> </defaultUI> </configuration>
airupdate.xml
<?xml version="1.0" encoding="utf-8"?> <update xmlns="http://ns.adobe.com/air/framework/update/description/1.0"> <version>0.2</version> <url>http://mojalog.com/yaruo.air</url> <description>This is the latest version of the Sample application.</description> </update>
で、0.2バージョンのairパッケージを作ってサーバに置く。ローカルでは0.1のパッケージを作ってインストールする。バージョンはapplication.xmlで記述する。↓はローカル用の0.1のものサーバにあげるのは0.2。パッケージの中まで見てるかは知らない。
app.xml
<?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://ns.adobe.com/air/application/1.0"> <id>air.yaruoWorld</id> <version>0.1</version> <filename>yaruoWorld</filename> <initialWindow> <title>yaruoWorld</title> <content>yaruoWorld.html</content> <visible>true</visible> <systemChrome>standard</systemChrome> <transparent>false</transparent> <width>340</width> <height>300</height> </initialWindow> </application>
署名
adt –certificate -cn SelfSigned 1024-RSA hoge.pfx hoge
パッケージング
adt -package -storetype pkcs12 -keystore hoge.pfx yaruo.air app.xml yaruoWorld.html updateConfig.xml applicationupdater_ui.swf applicationupdater.swf AIRAliases.js










