I have implemented the logic for component/page update notification using event handle.
please find below source code.
Step1:
Create a new SDLResponder.js file
SDLWeb.ContentManager.SDLResponder = function SDLResponder() {
Tridion.OO.enableInterface(this, "Tridion.ContentManager.SDLResponder");
this.addInterface("Tridion.MarshallableObject");
this.addInterface("Tridion.InitializableObject");
this.initialize();
};
SDLWeb.ContentManager.SDLResponder.IDENTIFIER = "tcm:SDLResponder";
SDLWeb.ContentManager.SDLResponder.prototype._initialize = function SDLResponder$_initialize() {
this.callBase("Tridion.InitializableObject", "_initialize");
SDLWeb.Web.UI.Core.NotificationBroadcaster.getInstance().addEventListener("notification", this.getDelegate(this.handleNotification));
};
SDLWeb.ContentManager.SDLResponder.prototype.handleNotification = function SDLResponder$handleNotification(event) {
if (event.data !== null) {
var id = Tridion.ContentManager.UserSettings.getJsonUserSettings(true).User["@ID"];
var data = event.data;
if (data.details.userId !== null && data.details !== undefined) {
if (data.details !== null && data.details.userId !== null && data.details.userId == id) {
switch (data.action) {
case "PageSave":
//MessageCenter$registerNotification(title, description, local, modal, htmlDescription) for hyperlinks to work send true for html description
$messages.registerNotification("Notification", "" + data.details.messageNotification, true, null, true);
break;
case "ComponentSave":
//MessageCenter$registerNotification(title, description, local, modal, htmlDescription) for hyperlinks to work send true for html description
$messages.registerNotification("Notification", "" + data.details.messageNotification, true, null, true);
break;
}
}
}
}
};
if (!$models.getFromRepository(SDLWeb.ContentManager.SDLResponder.IDENTIFIER)) {
$models.createInRepository(SDLWeb.ContentManager.SDLResponder.IDENTIFIER, "SDLWeb.ContentManager.SDLResponder");
};
Step2: Added below line into editor.config:
<cfg:file type="script">/Notifications/SDLResponder.js</cfg:file>
**
Event handler code for component update:
**
public void SendSoftNotificationMessage(Component component)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
string notificationmessage = string.Empty;
string softNotificationMessage = string.Empty;
string emailnotificatioinmessage = string.Empty;
Dictionary<string, object> componentDic = new Dictionary<string, object>();
var session = component.Session;
componentDic.Add("userId", session.AccessToken.Id.ToString());
componentDic.Add("reasons", emptyarray);
softNotificationMessage = string.Format(EventHandlerConstants.Message, component.Title ));
notificationmessage = string.Format(EventHandlerConstants.SoftNotificationMessage, component.Title, softNotificationMessage);
componentDic.Add("messageNotification", notificationmessage);
string jsonString = serializer.Serialize((object)componentDic);
var message = new NotificationMessage
{
Action = "ComponentSave",
SubjectIds = new[] { component.Id.ToString() },
Details = jsonString
};
session.NotificationsManager.BroadcastNotification(message);
}