I’m using phone gap push plugin and local notifications plugin to implement push notifications. Currently when clicked on notification, the home page is opened. But i need to open notification related page when clicked on it. Tried the following code, but did not work.
this.localNotifications.on(“click”).subscribe((notification:any)=>
{
let json = JSON.parse(notification.data);
let alert = this.alertCtrl.create({
title: notification.title,
subTitle: json.mydata
});
alert.present();
});
Tahnks for replying. The application which we are implementing is a basic news feed application. A push notification is sent to the user whenever a new news item is added. and when the user clciks on the notification, i need to open that particular news item
So you just need to do that in your app.component.ts :
import { App } from "ionic-angular";
then in constructor
private app: App,
then after register push notifications in app.component.ts
this.localNotifications.on("click").subscribe((notification:any)=>
{
let nav = this.app.getActiveNav();
nav.push("NewsDetailsPage", {
newsID: "PUT THERE YOUR NEWS ID IF U WANT TO NAVIGATE TO NEWS"
});
});
Tell me if that helps you or u need more explanation