你好我试图使用cordoba插件进行条形码扫描器windows phone 8,使用mobilefirst 7.1,并且在插件正确读取de barcode之后(我只是放了一些断点并且e.Barcode有条形码值),plagin < / p>
private void TaskCompleted(object sender, BarcodeScannerTask.ScanResult e)
{
PluginResult result;
switch (e.TaskResult)
{
case TaskResult.OK:
result = new PluginResult(PluginResult.Status.OK, JsonHelper.Serialize(new BarcodeResult(e.Barcode)));
// result.Message = ;
break;
case TaskResult.Cancel:
// If scan is cancelled we return PluginResult.Status.OK with Message contains cancelled: true
// See plugin docs https://github.com/MSOpenTech/BarcodeScanner#using-the-plugin
result = new PluginResult(PluginResult.Status.OK, JsonHelper.Serialize(new BarcodeResult()));
// result.Message =;
break;
default:
result = new PluginResult(PluginResult.Status.ERROR,"Error default");
break;
}
DispatchCommandResult(result);
}
代码进入TaskResult.OK,然后正确创建响应对象,接下来:执行DispatchCommandResult(result)并返回我的javascript代码,但回调函数从未被调用过。
任何帮助?
答案 0 :(得分:0)
因为你没有提供web部分(JS实现),所以很难知道为什么它没有调用回调函数。
我建议您查看适用于Windows Phone 8的Cordova插件教程,并验证您是否正确实现了JS部件。
function sayHello() {
var name = $("#NameInput").val();
cordova.exe(sayHelloSuccess, sayHelloFailure, "SayHelloPlugin", "sayHello", [name]);
}
function sayHelloSuccess(data){
WL.SimpleDialog.show(
"Response from plug-in", data,
[{text: "OK", handler: function() {WL.Logger.debug("Ok button pressed");}}]
);
}
function sayHelloFailure(data){
WL.SimpleDialog.show(
"Response from plug-in", data,
[{text: "OK", handler: function() {WL.Logger.debug("Ok button pressed");}}]
);
}