Main goal is to add to site ability to send web notification to pop up a system notification to alert the user using Html5 Push API and service workers. Not using SignalR which only can run client scripts while site is opened. Also should be ability to send notification if site is closed, as mentioned here - it is possible.
Here is good article about Push API and provided good example But it uses NodeJS as server and web-push component to send requests to notification services.
Can't find any .NET examples. I think about the two workarounds.
First, is to write everything from scratch based on Push API article note about server:
When you send a push message without data, you simply send it to the endpoint URL using an HTTP POST request. However, when the push message contains data, you need to encrypt it, which is quite a complex process.
Second, is to use AspNetCore.NodeServices (article about it) to execute node.js script file
Are there more solutions? Maybe exists ready solution for this?
After subject researching
3 cases:
- HTTP + old browsers + IE all versions - Use SignalR + render Notification using html+js
- HTTP + Modern browsers (Chrome, Firefox, Safary, Opera?, Edge) with support of Notification API. - Use SignalR and trigger native browser notification with js using
new Notification('Message')
- HTTPS + Chrome (Mobile) with support of Push API to trigger native notification for closed site using service-workers. Mobile version of Chrome can create notifications only by using service-worker.
It's became to complicated. What is wrong?
Possible solutions:
For 1 and 2 cases found this repository. Think it is a good frontend solution with a good fallback support. For 3 case still don't know what to do.
Current solution. Added: 2017-11-22
- No offline clients notifications support
- No mobile support
- For Chrome v62+ moving all project to https - link
- Using SignalR (0.2.0) for sending push to online clients
- Using pnotify v3+ to show native desctop or html notifications.
- Waiting for pnotify v4.0.0 (author promises chrome mobile support. Issue)
- Waiting for .NET Core 2.1 with SignalR 1.0 to rewrite whole project to it.
POST /projects/PROJECT_ID/notifications
). – Hayrack