Cordova和Windows Phone,呼叫cordova.exec

时间:2013-11-07 14:32:53

标签: javascript cordova windows-phone-8

我需要一些帮助尝试使用Phonegap使用cordova.exec执行插件。

我按照教程:WP plugin tutorial

但是当我尝试运行时,我收到以下错误:

Error::Plugin not allowed in config.xml. Echo

以下是我如何通过javascript调用它:

cordova.exec(function(){ console.log("success");}, function(){console.log("fail");}, "Echo", "echo", ["input string"]);

这是我的Echo.cs

using WPCordovaClassLib.Cordova;
using WPCordovaClassLib.Cordova.Commands;
using WPCordovaClassLib.Cordova.JSON;

namespace Cordova.Extension.Commands
{
    public class Echo : BaseCommand
    {
        public void echo(string options)
        {
          string optVal = JsonHelper.Deserialize<string[]>(options)[0];

          DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "Everything went as planned, this is a result that is passed to the success handler."));
        }
    }
}

1 个答案:

答案 0 :(得分:1)

只需添加到config.xml

<feature name="Echo">
    <param name="wp-package" value="Echo" />
</feature>

插件名称=“Echo”已弃用且不再有效