Removing Pushwoosh NotificationReceived event listener OnDestroy

Removing Pushwoosh NotificationReceived event listener OnDestroy

  
Invalid call of the 'NotificationReceived' client action of the 'MainFlow.DashboardHome' 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 can I remove this Pushwoosh event listener OnDestroy of each screen to prevent these errors?
Thanks.

Hello Daniel,

From a search, I found this: https://www.outsystems.com/forums/discussion/21187/invalid-call-of-the-onnotificationreceived-client-action/

Could you test if the code provided by Carlos Simões works for you?
You can put the code in a JavaScript in the screen OnDestroy.

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);
    });
});

Let me know if it works for you, please.


Cheers,
Eduardo Jauch

Eduardo Jauch wrote:

Hello Daniel,

From a search, I found this: https://www.outsystems.com/forums/discussion/21187/invalid-call-of-the-onnotificationreceived-client-action/

Could you test if the code provided by Carlos Simões works for you?
You can put the code in a JavaScript in the screen OnDestroy.

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);
    });
});

Let me know if it works for you, please.


Cheers,
Eduardo Jauch

I haven't had a chance to test this yet but thank you for digging it up.  We are receiving similar errors on various other callbacks, and I'm assuming it is because the user has navigated away from the page before the callback is fired.

Not that big of a deal except that it dirties up the error log :)

I will test this as soon as I can.