【问题标题】:Barcode scanner plugin windows phone 8 doesnt execute callback条码扫描器插件 windows phone 8 不执行回调
【发布时间】:2016-04-19 12:42:09
【问题描述】:

您好,我正在尝试使用用于条码扫描仪 windows phone 8 的cordoba 插件,使用 mobilefirst 7.1,并且在插件正确读取 de 条码后(我只是放置了一些断点并且 e.Barcode 具有条码值),plagin

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代码,但从未调用回调函数。

有什么帮助吗?

【问题讨论】:

  • 你用的是哪个条码插件...
  • 如果您在纯 Cordova 样本中尝试相同的方法,它会起作用吗?只有在 MFP 7.1 WP8 应用程序中运行时才会出现问题吗?
  • @user2449016 那么问题呢 - 如果没有 MFP,它是否也会失败...?

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


【解决方案1】:

因为你没有提供 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");}}]
    );
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-11
    • 1970-01-01
    • 1970-01-01
    • 2011-05-24
    相关资源
    最近更新 更多