IBM Mobilefirst 7 无法进行本机函数调用

IBM Mobilefirst 7 unable to make native function calls

我是 运行 一个应用程序,使用 IBM MobileFirst 7 在 iOS 8.4 上创建。起初它工作正常:我可以写入 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;
}

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

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