removePushNotificationListener( PushNotificationListener, [containingObject] ) method

Remove the push notification listener.

This function should be called with identical parameters that were used to add the push notification listener with hwc.addPushNotificationListener.

Syntax

<static> removePushNotificationListener( PushNotificationListener, [containingObject] )

Parameters

Name Type Argument Description
PushNotificationListener anonymous.PushNotificationListener   The callback for push notifications.
containingObject Object (optional) The containing object of the listener.

Example

// pushListener is the callback function that will be passed to hwc.addPushNotificationListener.
var pushListener = function( notifications )
{
   alert( "push notification:\
" + JSON.stringify(notifications) );
   return hwc.NOTIFICATION_CONTINUE;
}
hwc.addPushNotificationListener( pushListener );
// At some other point if we want to remove the push listener, we call the following line:
hwc.removePushNotificationListener( pushListener );
// pushListenerManager is an object that will contain the listener callback as well as a variable
// referenced from the callback.
var pushListenerManager = {};
// doSomething is a function that is called from inside the callback.
pushListenerManager.doSomething = function( notifications )
{
   alert( "push notification:\
" + JSON.stringify(notifications) );
   return hwc.NOTIFICATION_CONTINUE;
}
// This is the callback function.
pushListenerManager.listener = function( notifications )
{
   return this.doSomething( notifications );
}
// Since the callback function references variables in its containing object, the containing object
// must be passed to hwc.addPushNotificationListener as well.
hwc.addPushNotificationListener( pushListenerManager.listener, pushListenerManager );
// when we want to remove the push listener, we call the following line:
hwc.removePushNotificationListener( pushListener, pushListenerManager );

Source

hwc-api.js, line 1299.