How can I listen to the notification click event.(Ionic2 notification click event)


#1

I am developing push notification application in Ionic2.Notifications are coming.I want to redirect to a page(PushPage) want when click on the notification.How can I listen to the notification click event

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core'; 
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { CloudSettings, CloudModule } from '@ionic/cloud-angular';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import {PushPage} from '../pages/push/push';

const cloudSettings: CloudSettings = {
  'core': {
  'app_id': 'xxxxxx'
 },
   'push': {
      'sender_id': 'xxxxxxxxx',
      'pluginConfig': {
      'ios': {
      'badge': true,
      'sound': true
     },
     'android': {
     'iconColor': '#343434'
     }
    }
   }
  };

   @NgModule({
    declarations: [
    MyApp,
    HomePage,
    PushPage
   ],
   imports: [
   BrowserModule,
   IonicModule.forRoot(MyApp),
   CloudModule.forRoot(cloudSettings)
  ],
   bootstrap: [IonicApp],
   entryComponents: [
   MyApp,
   HomePage,
   PushPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
 })
 export class AppModule {}

app.component.ts

import { Component } from '@angular/core';
 import { Platform } from 'ionic-angular';
 import { StatusBar } from '@ionic-native/status-bar';
 import { SplashScreen } from '@ionic-native/splash-screen';

 import {
  Push,
  PushToken
  } from '@ionic/cloud-angular';



   import { HomePage } from '../pages/home/home';
   @Component({
   templateUrl: 'app.html',


  })
   export class MyApp {
   rootPage:any = HomePage;

   constructor(platform: Platform, statusBar: StatusBar, splashScreen: 
   SplashScreen,
   public push:Push) {
    platform.ready().then(() => {
    // Okay, so the platform is ready and our plugins are available.
    // Here you can do any higher level native things you might need.
    statusBar.styleDefault();
    splashScreen.hide();
   });

    this.push.register().then((t: PushToken) => {
    return this.push.saveToken(t);
   }).then((t: PushToken) => {
   console.log('Token saved:', t.token);
  });

  this.push.rx.notification()
  .subscribe((msg) => {
  alert(msg.title + ': ' + msg.text);
  });

 }

 }