我正在尝试构建一个ionic2应用程序,该应用程序向用户发送一些指导通知,我想在用户单击通知而不是主页时将用户发送到特定页面。这是我的代码:
public schedule(title, text) {
LocalNotifications.schedule({
title,
text,
at: new Date(new Date().getTime() + 1* 1000)
});
}
LocalNotifications.on("click", (notification, state) => {
let alert = this.alertCtrl.create({
title: this.todos[this.num].info.nom_du_musee,
subTitle: this.todos[this.num].info.periode_ouverture+" "+this.todos[this.num].info.adr+" site web "+this.todos[this.num].info.sitweb,
buttons: ["OK"]
});
alert.present()
});
}
您可以
根据 https://ionicframework.com/docs/api/components/alert/AlertController/向按钮添加处理程序
let alert = this.alertCtrl.create({
title: this.todos[this.num].info.nom_du_musee,
subTitle: this.todos[this.num].info.periode_ouverture+" "+this.todos[this.num].info.adr+" site web "+this.todos[this.num].info.sitweb,
buttons: [
{
text: 'OK',
handler: () => {
console.log('OK clicked');
}
}
]
});
alert.present()
下一阶段是用代码替换控制台.log推送新页面..
this.navCtrl.push(DestinationPage);