I am developing a cordova plugin for windows desktop and I need to use some native functions, I will have to use Windows Runtime. I started by following a tutorial and I have the following structure:
- /src
- /EchoRuntime
- /bin
- /obj
- /Properties
- EchoPluginRT.cs
- EchoRuntimeComponent.csproj
- echopluginProxy.js
- /www
- echoplugin.js
- plugin.xml
At the code level I have the following:
plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="com.teste.echoplugin" version="0.1.0">
<name>EchoPlug</name>
<description>Echo demo plugin for Apache Cordova</description>
<license>MIT</license>
<keywords></keywords>
<repo></repo>
<issue></issue>
<js-module src="www/echoplugin.js" name="echoplugin">
<clobbers target="window.echoplugin" />
</js-module>
<!-- windows8 -->
<platform name="windows">
<js-module src="src/windows/echopluginProxy.js" name="EchoProxy">
<merges target="" />
</js-module>
<framework src="src/windows/EchoRuntime/EchoRuntimeComponent.csproj" custom="true" type="projectReference"/>
</platform>
/www/echoplugin.js
var EchoPlugin = {
// the echo function calls successCallback with the provided text in strInput
// if strInput is empty, it will call the errorCallback
echo:function(successCallback, errorCallback, strInput) {
cordova.exec(successCallback,errorCallback,"EchoPlugin","echo",[strInput]);
}
}
module.exports = EchoPlugin;
/src/echopluginProxy.js
cordova.commandProxy.add("EchoPlugin",{
echo:function(successCallback,errorCallback,strInput) {
var res = EchoRuntimeComponent.EchoPluginRT.echo(strInput);
if(res.indexOf("Error") == 0) {
errorCallback(res);
}
else {
successCallback(res);
}
}
});
/src/EchoRuntime/EchoPluginRT.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EchoRuntimeComponent
{
public sealed class EchoPluginRT
{
public static string echo(string valor)
{
return " PASSOU AQUI";
}
}
}
Only with JavaScript I've managed to get it to work now with the C # function, it's not. Can anyone help?