Hi, I’m trying to update badge value by using event methode from a provider. It seems ok on Android but not on iOS.
Provider extract… (Event sender)
import { Events } from 'ionic-angular';
@Injectable()
export class theProvider{
constructor( public events: Events ) { }
oneProviderJob() {
.
.
// To update badge of pageTwo
this.events.publish('cart:updated', 10);
.
.
}
}
And then we subscribe to that event in the tabs that contains both pages: (pageOne & pageTwo)
Notice that all pages are declered in an array… but why not?
import { Component } from '@angular/core';
import { Events } from 'ionic-angular';
@Component({...})
export class TabsPage {
allTabs =[];
constructor(public events: Events) {
this.allTabs = [
{ root=FirstPage title="Page one" badge=0 },
{ root=SecondPage title="Page two" badge=0 }
]
event.subscribe('cart:updated', _badgeValue => {
this.allTabs[1].badge = _badgeValue;
});
}
}
And in the view:
<ion-header>
<ion-navbar>
<ion-title>Tabs</ion-title>
</ion-navbar>
</ion-header>
<ion-tabs #myTabs>
<ion-tab *ngFor="let tab of allTabs" [root]="tab.root" tabTitle="tab.title" tabBadge="tab.badge"></ion-tab>
</ion-tabs>
It is ok on Andoid devices.But, it does NOT OK on iOS ones.
On iOS, the bagge will be update only after that the SecondPage works on its view. (Update it)
I use the ionic release. (3.19.0)
Thanks in advance for your help.