Question

How do you initialize a NotificationController in DNN 7.1.2?

I've tried:

var nc = new DotNetNuke.Services.Social.Notifications.NotificationController();

However this is empty and has no methods to call... Am I initializing the wrong thing?

Surely there should be something in there other than ToString, GetType, Equals and GetHashCode

I need to be able to create NotificationTypes and create Notifications.

Thanks

Was it helpful?

Solution

You can use NotificationsController.Instance.SendNotification method to send notifications. Here is the example:

var notificationType = NotificationsController.Instance.GetNotificationType("HtmlNotification");
var portalSettings = PortalController.GetCurrentPortalSettings();
var sender = UserController.GetUserById(portalSettings.PortalId, portalSettings.AdministratorId);

var notification = new Notification {NotificationTypeID = notificationType.NotificationTypeId, Subject = subject, Body = body, IncludeDismissAction = true, SenderUserID = sender.UserID};
NotificationsController.Instance.SendNotification(notification, portalSettings.PortalId, null, new List<UserInfo> { user });

This will send notification to a specific user.

OTHER TIPS

If you need to create your own Notification type use the code below as a guide, it will create a NotificationType "GroupApprovedNotification". This is from core groups module.

type = new NotificationType { Name = "GroupApprovedNotification", Description = "Group Approved Notification", DesktopModuleId = deskModuleId };
if (NotificationsController.Instance.GetNotificationType(type.Name) == null)
{
    NotificationsController.Instance.CreateNotificationType(type);

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top