【问题标题】:IBM Mobilefirst 7 unable to make native function callsIBM Mobilefirst 7 无法进行本机函数调用
【发布时间】:2015-10-23 10:38:31
【问题描述】:

我正在 iOS 8.4 上运行使用 IBM MobileFirst 7 创建的应用程序。起初它工作正常:我可以写入 jsonstore 并进行其他本机函数调用。

然后应用程序开始同步并写入 JSONStore(大量数据)并在一段时间后停止(控制台中没有错误)。它通常在尝试调用 WL.Client.invokeProcedure 函数时发生。

我还注意到一个奇怪的行为:如果我双击主页按钮,它会在循环中进行下一个 WL.Client.invokeProcedure 调用,并且我从适配器接收结果但随后它再次停止(每次我双击主页按钮发生这种情况)。其他本机调用也会发生这种情况(例如,我尝试使用 cordova 在 JS 控制台中调用其他本机函数,并且只有在我双击主页按钮后才会调用它)。

有谁知道是什么导致了这种行为?~

编辑:

关于本机调用:由于我使用的是cordova,我可以使用插件来访问一些本机功能,例如:

//this is what I meant by "native function calls"
cordova.exec(successCallback, errorCallback, 'SFRPowerSave', 'enable', []);

我不确定 WL.Client.invokeProcedure 和 WL.JSONStore 函数,但我认为它们也使用本机代码。

这就是我正在做的事情:

//I get the first 50 dirty documents
function push(){
    var numberOfDocumentsToPush = 50;
    var dirtyDocuments = currentSyncStore.dirtyDocuments.splice(0, numberOfDocumentsToPush);

    //then I call the adapter add method and return a promise
    return when(WL.Client.invokeProcedure({
        adapter : adapter.name,
        procedure : adapter.push.procedure,
        parameters : [ JSON.stringify(dirtyDocuments), 
                       JSON.stringify({add: addParams}) ],
        compressResponse : false
    }, {
        timeout: adapter.timeout,
        invocationContext: {context: this, document: dirtyDocuments}
    });
}
//after the promise is returned, I get the next 50 dirty documents and call the push function again, I usually have a lot of dirtyDocuments (lets say 10000). 
//After a while it just stops, the WL.Client.invokeProcedure doesn't reject or resolve the promise and no timeout occurs.
//I can interact with the interface of the application but if I try to call some native function, it will not work (but it gets called immediatly after entering the multitask mode - double tap home button in ipad/iphone)


//In the adapter I call the stored procedure from the DB2 database one time for each document:
function pushLogs(logs, params, addFunction){
    var parsedParams = JSON.parse(params);
    var addParsedParams = parsedParams.add;


    var addConfig = getConfig("logs", addFunction, JSON.stringify(addParsedParams));

    var parsedLogs = JSON.parse(logs);

    var globalResult = {
            isSuccessful: true,
            responses: []
    };

    for (var i = 0; i < parsedLogs.length; i++) {
        var options = {
                values : JSON.stringify(parsedLogs[i].document),
                spConfig: addConfig
        };

        var result = invokeSQLStoredProcedure(options);

        globalResult.isSuccessful = globalResult.isSuccessful && result.isSuccessful;

        globalResult.responses.push(result);
    }

    return globalResult;
}

【问题讨论】:

  • 您需要提供一个具体示例来说明您正在做什么 - 复制 - 一个可以观察和调试的代码小测试用例。您还需要更好地定义“本机函数调用”是什么意思。
  • 您好 Idan Adar,感谢您回答我的问题。我在问题中添加了一些细节,您可以再看一下吗?谢谢。

标签: ios ibm-mobilefirst jsonstore


【解决方案1】:

已打开 PMR 来处理此问题。事实证明这是一个 Cordova 缺陷,现在正在通过 APAR PI47657 处理:应用程序在尝试异步调用 JSONStore 以同步数据时挂起

该修复将出现在未来的 iFix 版本中,可从 IBM Fix Central 获得(以及通过打开的 PMR)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-07
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多