Cordova 2.0.0 用のカスタム プラグインを作成しようとしています。作成したいカスタム プラグインは WP のアクセント カラーを取得する必要があるため、アプリの Style で使用できます。
しかし、私はそれを適切に機能させることができず、何が間違っているのかを理解できません。
Index.js
function onDeviceReady() {
click();
}
function click() {
navigator.notification.alert(callback, callback, "text", "button");
window.getAccentColor();
}
GetTheme.cs
namespace Cordova.Extension.Commands
{
// Use the phonegap base class
public class GetTheme : BaseCommand
{
public void Get()
{
Color currentColorHex = (Color)Application.Current.Resources["PhoneAccentColor"];
var result = new PluginResult(PluginResult.Status.OK, currentColorHex.ToString());
DispatchCommandResult(result);
}
}
}
GetTheme.js
window.getAccentColor = function () {
cordova.exec(win, error, "GetTheme", "Get");
}
function win(result) {
console.log(result);
console.log("2");
};
function error() {
}
私が気づいたいくつかの奇妙なことがあります。クリックアクションの通知ポップアップでは、「2」が出力に書き込まれます。しかし、それがなければ何も出力されません。
どちらの場合もresult
、 fromwin
関数はまだ空で、何も出力しません。
すべての *.js ファイルはindex.html
、head セクションのファイルに含まれています。通知からのコールバック メソッドが定義されていますが、何もしません。
WP7CordovaClassLib.Cordova.Commands
名前空間も試しました。