我正在尝试为科尔多瓦2.0.0编写自定义插件。 我想制作的自定义插件必须获取WP重音颜色,所以我可以在应用程序样式中使用它。自定义科尔多瓦插件
但我无法设法使其正常工作,无法弄清楚我做错了什么。
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
从win
功能仍然是空的,并没有任何输出。
所有* .js文件都包含在头部的index.html
文件中。 通知中的回调方法已定义,但它什么都不做。
我也尝试了WP7CordovaClassLib.Cordova.Commands
命名空间。
感谢您的回答,但不幸的是它没有帮助。我删除了一些无用的测试代码,并且我注意到我的插件甚至没有被调用。 – sebastian