Good day,
I am trying to push notifications from server to client side using abp notification system.
My StartUp.cs:
public class Startup
{
public void Configuration(IAppBuilder app)
{
...
app.MapSignalR();
}
}
My Web Service:
public class ContactFormsAppService : REPAppServiceBase, IContactFormsAppService
{
private readonly IAppNotifier _appNotifier;
public ContactFormsAppService(IAppNotifier appNotifier)
{
_appNotifier = appNotifier;
}
public void SendMessageForOffice()
{
_appNotifier.SendMessage(101, "Message");
}
}
AppNotifier:
public class AppNotifier : REPDomainServiceBase, IAppNotifier
{
private readonly INotificationPublisher _notificationPublisher;
public AppNotifier(INotificationPublisher notificationPublisher)
{
_notificationPublisher = notificationPublisher;
}
public async Task SendMessage(long userId, string message, NotificationSeverity severity = NotificationSeverity.Info)
{
await _notificationPublisher.PublishAsync(
"App.SimpleMessage",
new MessageNotificationData(message),
severity: severity,
userIds: new[] { userId } );
}
}
I can see messages in debugger console in the browser:
abp.js:285 DEBUG: abp.js:285 Connected to SignalR server! abp.js:285 DEBUG: abp.js:285 Registered to the SignalR server!
However, the event in header.js is never fired:
abp.event.on('abp.notifications.received', function (userNotification) {
console.log("notification!", userNotification);
});
Any help would be greatly appreciated.
7 Answer(s)
-
0
Hi,
Which version of ABP do you use ? I remember a similar issue in the one of previous versions.
-
0
Have you registered to the "App.SimpleMessage" notification from the current user? <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Notification-System#subscribe-to-notifications">http://www.aspnetboilerplate.com/Pages/ ... ifications</a>
-
0
I'm seeing the same issue.
My client subscribes to receive the notifications, the server publishes a notification, but it's not received. :|
-
0
<cite>ismcagdas: </cite> Hi, Which version of ABP do you use ? I remember a similar issue in the one of previous versions.
0.8.4.0
<cite>hikalkan: </cite> Have you registered to the "App.SimpleMessage" notification from the current user? <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Notification-System#subscribe-to-notifications">http://www.aspnetboilerplate.com/Pages/ ... ifications</a>
Yes, I had.
await _notificationSubscriptionManager.IsSubscribedAsync(recepient.Id, "App.SimpleMessage");
returns true.
-
0
Hi,
It seems liek you are using this version <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/releases/tag/v1.9.1.1">https://github.com/aspnetzero/aspnet-ze ... g/v1.9.1.1</a>. I have downloaded this release and tried to send a notification (just entered .../Account/TestNotification to browser) and it seems like it's working.
So, it's not related to Abp 0.8.4.
There are two things comes to my mind,
1 ) is there any other code after app.MapSignalR(); in your Startup.cs's configure method ? 2) Is there any other tab/browser window opened with the same account. Because for your version (Abp 0.8.4), the notification will be sent to only last opened browser window/tab.
-
0
<cite>ismcagdas: </cite>
Hi, 1 ) is there any other code after app.MapSignalR(); in your Startup.cs's configure method ?
No.
<cite>ismcagdas: </cite>
- Is there any other tab/browser window opened with the same account. Because for your version (Abp 0.8.4), the notification will be sent to only last opened browser window/tab.
No.
-
0
Thank you, solved. The problem was related with business logic of the application and had nothing to do with ABP or SignalR.