I'm trying to make a notification page which is opening from tabs. After opening the page, it needs to refresh itself so the new notifications will be visible as well as these notifications will be checked as read and the badge on the tabs will be 0.
The first time you open the notification page, it enters the constructor but it doesn't enter again.
It was working well before but then it stops working, I don't know why.
Notification Page;
constructor(public events: Events, public navCtrl: NavController, public
navParams: NavParams, private notificationservice: NotificationService,
private loadingCtrl: LoadingController) {
this.notificationservice.getNotifications(AuthService.currentUser.UserId).then(
data => {
this.notifications = data;
this.notificationservice.unreadNotificationCount().then(data => {
if(data != 0)
{
this.notificationservice.readNotification().then(data => {
this.updateBadge();
this.navCtrl.setRoot(this.navCtrl.getActive().component);
});
}
});
});
}
public updateBadge()
{
this.notificationservice.unreadNotificationCount().then(data => {
console.log(data);
this.events.publish('cart:updated', data);
});
}
Tabs Page;
constructor(public navCtrl: NavController, public navParams: NavParams,
private notificationservice: NotificationService, public events: Events) {
this.updateBadge();
this.events.subscribe('cart:updated', (count) => {
this.badge = count;
});
}
public updateBadge()
{
this.notificationservice.unreadNotificationCount().then(data => {
console.log(data);
this.events.publish('cart:updated', data);
});
}
Tabs view;
