push notifications using Blazor Server

Viewed 3942

I have a Blazor Server app on which users can subscribe to an asset and whenever the asset changes the UI is updated. That already works.

Now I would like to implement a feature that when change's severity is "Critical" not only the UI updates but the user also gets a push notification. Let's assume that a change is represented with such class:

public class MyChange
{
   public string Severity { get; set; }
}

Is this even possible with Blazor Server, if so then how? Or should I use Blazor WebAssembly?

1 Answers

Not sure which part is not working and what was implemented for the push. But to give you a full answer yes you can do this. With SignalR you can send Push messages to the clients. Actually Server hosted Blazor already using SignalR to update HTML but you can use it for Balzor WASM as well.

Once you set up push messages and clients receives it then you can show Notifications. You can use this Nuget also docs and demo available. To prompt one of the following notifications:

  • Alerts: static "banner" (this has severity check Type property) Alert demo
  • Toast messages: more dynamic "popup" like message inside your app (this has severity check Type property) Toast demo
  • HTML5 Notification API: system notifications outside of your app (you cannot really "style" System notifications)
Related