Hi. I am sending a notification to the phone with FCM. According to a code in this notification, I want to redirect to that page when opening the application. How can I do it? The code below opens the home page of the application directly.
in app.components.ts:
this.fcm.onNotification().subscribe(data => {
var noti_data = data['body'].split(" ");
var noti_type = noti_data[noti_data.length-1];
if (data.wasTapped) {
if(noti_type == "XX001")
{
alert("111");
this.route.navigate(['/address']);
}
else if (noti_type == 'XX002')
{
alert("222");
this.route.navigate(['/home/address2']);
}
else if (noti_type == 'XX003')
{
alert("333");
this.route.navigate(['/home/address3']);
}
console.log('Received in background');
} else {
console.log('Received in foreground');
}
});
It works when I put the same code block in foreground.
1 post - 1 participant