docsforge.event.connectionStateChange.addListener
から使用しようとしています。完全に空のアプリケーションを作成し、構成に追加し、次のビットを .xml に追加しました。"event":true
config.json
main.js
forge.logging.info("Add JavaScript to js/main.js!");
forge.event.connectionStateChange.addListener(
function() {
alert('Device ' + (forge.is.connection.connect() ? "is" : "is not") + 'connected.');
},
function(){
alert('Erorr');
}
);
アプリケーションを実行してマシンの Wi-Fi をオフにすると、アプリケーションがクラッシュします。必要に応じて、さらにログを提供できます。
[DEBUG] Native call: {
[DEBUG] callid = "9B3DBB44-870E-438B-8128-07E88474DDAB";
[DEBUG] method = "launchimage.hide";
[DEBUG] params = {
[DEBUG] };
[DEBUG] }
[DEBUG] Returning to javascript: {
[DEBUG] callid = "9B3DBB44-870E-438B-8128-07E88474DDAB";
[DEBUG] content = "<null>";
[DEBUG] status = success;
[DEBUG] }
[INFO] No reload update available.
[INFO] 2013-03-04 16:59:54.725 Forge[68603:c07] +[BorderControl returnResult:]: unrecognized selector sent to class 0x2fb4a4
[INFO] 2013-03-04 16:59:54.725 Forge[68603:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[BorderControl returnResult:]: unrecognized selector sent to class 0x2fb4a4'
[INFO] *** First throw call stack:
[INFO] (0x33b6012 0x2e55e7e 0x34412ad 0x33a5bbc 0x33a594e 0x2e695c8 0x2895765 0x3339f3f 0x333996f 0x335c734 0x335bf44 0x335be1b 0x33107e3 0x3310668 0x1d99ffc 0x26e6 0x2625)
[INFO] libc++abi.dylib: terminate called throwing an exception