Some questions about notifications

Hi! As the title suggests I have some questions about notifications.
I have a chat app made with Ionic and Firebase, very similar to Whatsapp or Facebook Messenger.

I was looking for a way to send a notification everytime someone sends you a new message. So far I’ve seen following this tutorial wich is in spanish

first question: In the tutorial it says that in order to get the notification you need to put this code in app.components.ts

private getNotifications(){
  .subscribe((msg) => {
    alert(msg.title + ': ' + msg.text);

And then you send the notification using the dashboard. Wich is cool, but lets say I want to send a notification everytime someone recieve a new message: Is there a way to put that code in the list view of the chats or maybe in a firebase function so everytime a new node chat is added to the DB it send the notification?

And the second question is: How good is compared to others like Onesignal? Is there a better alternative?


If you want to trigger push programmatically on Ionic Push, you are looking for