0

I have a notification system in the backend but I don't know how to implement it in the frontend side.

I want to make an AngularJs service that listens for any requests from the server and then I will display the notification(like facebook notification).Is this possible ?

this to overcome the problem of sending request every "period"to the server.

1
  • 1
    I usually make a request to the back-end, and use a notification to notify the user about that said request. If you want angular to display a notification on a server event by himself, I think you should look into socket.io Commented Nov 14, 2016 at 13:38

2 Answers 2

1

Since you are listening for data sent by the server, I assume you are using WebSockets. There is https://github.com/AngularClass/angular-websocket that slightly simplfies working with WebSockets in Angular.


If you are referring to PushNotifications, that is implemented in the ServiceWorker, not in the Angular app.

self.addEventListener('push', event => {
    let data = event.data.json();
    let title = '', args = {};

    title = 'Notification!!';
    args = { 'body': 'Hello hello',
             'icon': '/static/icon64.png',
             'tag': 'some-tag' };

    event.waitUntil(self.registration.showNotification(title, args));
});
Sign up to request clarification or add additional context in comments.

1 Comment

For anyone that looking for something similar, here's a good tutorial
0

You can user SignalR for real time to build real time notification system . Just specify the hub name, listening functions, and methods that you're going to use. This library can be useful.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.