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 Ionic.io following this tutorial wich is in spanish https://www.ion-book.com/blog/ionic2/ionic-push-notifications/

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(){
  this.push.rx.notification()
  .subscribe((msg) => {
    alert(msg.title + ': ' + msg.text);
  });
}

And then you send the notification using the ionic.io 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 Ionic.io compared to others like Onesignal? Is there a better alternative?

Thanks!

If you want to trigger push programmatically on Ionic Push, you are looking for https://docs.ionic.io/services/push/