4
  1. I am using phonegap-plugin-push for push notification in Ionic 3
  2. I received notification, but while clicking on notification I didn't get any response.
  3. I want to redirect to a selected page while clicking on notification. Below is my code.

    public pushNotification(){
      const options: PushOptions = {
        android: {
          senderID: 'xxxxxxxx',
          icon: 'icon',
          sound: true,
          vibrate: true
        },
        ios: {
          alert: true,
          badge: true,
          sound: true,
        }
      };
    
      let isNotifyAvailable: boolean = false;
      const pushObject: PushObject = this.push.init(options);
      let me = this;
      pushObject.on('notification').subscribe((notification: any) => {
        console.log('Received a notification', notification);
        if (notification.additionalData.foreground) {
          me.utilService.showToastMsg("success", notification.message);
        } else {
              this.navCtrl.setRoot(NotificationList);
        }
      });
    }
    
  4. In the backend I am using FCM notification in Python.

How can I redirect in selected page when click on Notification?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Apurv Chaudhary
  • 1,672
  • 3
  • 30
  • 55

1 Answers1

0
if (notification.additionalData.foreground) {
            // code as your functionality
} else {
        console.log("else", notification);
        this.handleNofication(notification.additionalData);
}

handleNofication(data) {
// here you can also pass data
    this.app.getRootNav().setRoot("RosterPage", { direction: "forward" });
  }
Pradip
  • 315
  • 1
  • 4
  • 12