条形码扫描程序插件Windows Phone 8不会执行回调

时间:2016-04-19 12:42:10

标签: javascript windows-phone-8 ibm-mobilefirst barcode-scanner

你好我试图使用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代码,但回调函数从未被调用过。

任何帮助?

1 个答案:

答案 0 :(得分:0)

因为你没有提供web部分(JS实现),所以很难知道为什么它没有调用回调函数。

我建议您查看适用于Windows Phone 8的Cordova插件教程,并验证您是否正确实现了JS部件。

见这里:https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/adding-native-functionality/windows-phone-8-adding-native-functionality-hybrid-application-apache-cordova-plugin/

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");}}]
    );
}