Samsung Electronics logo

Receiving Notifications on Content Changes



To create engaging applications with various content features, you must learn to receive notifications when content items are added, updated, or removed:

  1. Define the event handlers for different notifications using the ContentChangeCallback listener interface:

    var listener = 
    {
       /* When new items are added */
       oncontentadded: function(content) 
       {
          console.log(content.contentURI + " content was added");
       },
    
       /* When items are updated */
       oncontentupdated: function(content) 
       {
          console.log(content.contentURI + " content was updated");
       },
     
       /* When items are deleted */
       oncontentremoved: function(id) 
       {
          console.log(id + " was removed");
       }
    };
    
  2. Register the listener to use the defined event handlers:

    webapis.content.setChangeListener(listener);
    
  3. To stop the notifications, use the unsetChangeListener() method:

    webapis.content.unsetChangeListener();