addPushNotificationListener()

Adds a listener for a push notification. A user can only register a listener once until he or she removes the listener, or the listener is removed by another user. This method is only available in API version 26.0 or later.

For more information on push notifications, see Methods for Push Notifications.

Syntax 

1sforce.console.addPushNotificationListener( objects: array, eventHandler:Function )

Arguments 

NameTypeDescription
objectsarrayObjects set to receive notifications.
eventHandlerfunctionJavaScript method called when there is a push notification.

Sample Code–Visualforce 

1<apex:page>
2    <apex:includeScript value="/support/console/68.0/integration.js"/>
3    <script type="text/javascript">
4
5        var eventHandler = function (result) {
6            alert('There is a push notification of object: ' + result.Id);
7         };
8         //Add a push notification listener for Case and Account
9         sforce.console.addPushNotificationListener(['Case', 'Account'], eventHandler);
10    </script>
11</apex:page>

Response 

This method is asynchronous so it returns its response in an object in a callback method.

NameTypeDescription
idstringThe object ID of the push notification.
entityTypestringThe type of object included in the push notification. For example, Account or Contact. Objects available for push notifications are determined by the administrator who set up a Salesforce console.
TypestringThe field of the object included in the push notification. For example, the Account Name field on Account. Notifications occur when the field is either updated or created. Fields on objects available for push notifications are determined by the administrator who set up a Salesforce console.
LastModifiedByIdstringThe user ID of the user who last modified the object in the push notification.