Ionic cannot navigate to a specific tab upon notification clicked? -
i using ionic , fcm(firebase) plugin send push notification. can receive notifications, when tap notification triggers alert not navigating specified tab. make sure line:
this.tab.select(2);
works have tested navigating code button , works
fcmplugin.onnotification(function(data){ if(data.wastapped){ //notification received on device tray , tapped user. alert('data tapped'); this.tab.select(2); //this.navctrl.push(viewurgentnewspage); tried }else{ //notification received in foreground. maybe user needs notified. alert('this received on foreground'); } });
you should use arrow functions
fcmplugin.onnotification((data) => { if(data.wastapped){ //notification received on device tray , tapped user. alert('data tapped'); this.tab.select(2); } else { //notification received in foreground. maybe user needs notified. alert('this received on foreground'); } });
by using arrow function, this
keyword still references component code, this.tab
property exists.
Comments
Post a Comment