[Local Notifications Plugin] Invalid call of the 'OnNotificationReceived' client action 

[Local Notifications Plugin] Invalid call of the 'OnNotificationReceived' client action 

  
Forge Component
(2)
Published on 2016-12-15 by OutSystems R&D
2 votes
Published on 2016-12-15 by OutSystems R&D

Hi,

I've put notification block on layout block so it is to be present on all my pages and in my console I have multiple errors:

Invalid call of the 'OnNotificationReceived' client action of the 'MainFlow.MyScreenName' since the latter is not currently active. This is likely due to a platform's client action being used as an event handler or in a setTimeout function. Consider removing this call by using the 'On Destroy' event of the screen/block or moving your logic to a global client action.

How should I fix this?


Thank you.

Hey there, Mykola,

Just a quick check: are you using the latest platform version?

Best regards,

Carlos Simões

Hi Carlos.

Version 10.0.105.0

Hmmm, could you share your OnNotificationReceived flow, please?

Also, does the error occur on every screen access? Or after accessing multiple screens?

I've set notifications on one screen and then redirect to another where the error occurs one time. T.he script is in layout web block.

Hey again, Mykola,

I had a look and it looks like we might need to adjust the lifecycle of the plugin: apparently, there are callbacks bound to actions from a previous screen. We'll put an item on our backlog to revise this.

In the meantime, as a workaround, you can run this JavaScript on screen "OnDestroy" events to remove all callbacks:


var listeners = ["trigger", "click"];
listeners.forEach(function(event){
    var callbacks = cordova.plugins.notification.local.core._listener[event];
    callbacks.forEach(function(callback){
        cordova.plugins.notification.local.un(event, callback);
    });
});


Does this work for you?

Carlos Simões