Register a push notification listener.
<static> addPushNotificationListener( PushNotificationListener, [containingObject] )
Name | Type | Argument | Description |
PushNotificationListener | anonymous.PushNotificationListener | The callback for push notifications. | |
containingObject | Object | (optional) | Object containing definition for PushNotificationListener.If the listener callback function references variables in its containing object, then the containing object should be passed to this function. |
// 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 );
// 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 );