Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48983

Redirecting to a specific page based on the incoming push notification message -FCM

$
0
0

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

Read full topic


Viewing all articles
Browse latest Browse all 48983

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>