After following this helpful tutorial on Push Notifications with Angular 6 + Firebase Cloud Messaging, everything is working perfectly. I am able to receive notifications when using another browser.
To ensure that my notification list and the length of notifications get refreshed, I need to include the onInit()
function in the code snippet below:
receiveMessage() {
this.angularFireMessaging.messages.subscribe(
(payload) => {
console.log("new message received. ", payload);
this.currentMessage.next(payload);
this.navBar.onInit();
})
}
I have a Spring Boot backend setup and only require the refreshing of the notification list within the NavBar component.
Using FCM, I generate tokens for users in order to send notifications to others whenever updates are made in my Postgres DB.
Despite trying to store the payload value outside the function and even using CurrentMessage.next()
, the value seems to be null once outside the receiveMessage()
function. Is there a workaround to properly refresh my list?