Callback javascript functions

  

Hello!

Im really strugling getting a cordova plugin to work. Basicly, the cordova plugin has a bunch of javascript callback methods. But I can not get them to work.

I took a look at the Local notification plugin as an example but unfortenatly, I still can't get it to work.

This is an example of one of the callback functions I can't get working:

window.hybridmessaging.startMessagingService(function() {
        $actions.OnStartingServiceSuccess();
    }, function(error) {
        $actions.OnStartingServiceFailure();
    });

AM I missing some javascript code? If so, what am I missing? There is little to no documentation available on how to use javascript callback functions.

Greetings

Can anyone help me?

Hi Niels,

Where are you running that code? The action with it should be on the Render event of the Screen or Block where you wish to use that plugin. That way it will run once the screen loads.

Shouldn't callback run on the onReady of a screen?  


Greetings,

Niels

Hi Niels,

The callback is asynchronous, so the onReady action will continue to execute while we wait for the callback. If you want the JavaScript node to behave like a Promise and hold the onReady execution until the callback executes, you need to use a $resolve() to signal the end of the execution. Like this:

window.hybridmessaging.startMessagingService(function() {
        $actions.OnStartingServiceSuccess();
        $resolve();
    }, function(error) {
        $actions.OnStartingServiceFailure();
        $resolve();
    });


Niels Favreau wrote:

Shouldn't callback run on the onReady of a screen?  


Greetings,

Niels



Hello Niels,

I have no further insight into your direct question, but this documentation that explains the screen events may also be useful:

https://success.outsystems.com/Documentation/10/Developing_an_Application/03_Implement_Application_Logic/Screen_and_Block_Lifecycle_Events

And here you have more information regarding asynchronous JavaScript nodes.

https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/JavaScript/Defining_Asynchronous_JavaScript_Code

Let me know if it helps.

I putted call the javascript callback function in the onRender of a webblock in the Wrapper eSpace.
Afterwards I reference that webblock into my native appand a dragged the webblock in the Layout webblock.

If so, it's still not working. :/

On the native side, we checked the loading log. It seems the javascript functions aren't called at all, but the Plugin is loaded succesfully :/


Carlos Xavier wrote:

And here you have more information regarding asynchronous JavaScript nodes.

https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/JavaScript/Defining_Asynchronous_JavaScript_Code

Let me know if it helps.

I already tried it, but the documentation is about asynchronous client actions, not functions from a cordova plugin :/
When creating a new plugin, a 'RegisterPlugin' client action is auto generated(by outsystems) in the Onready of the webblock.
This javascript also has a console.log, but on the logs on native side, this log isn't even created, which means the javascript (Pluginmanager isn't even called :/



Hi Niels,

Can you provide me the plugin OML so I can test it here? I have no more ideas...