Javascript 如何更改离子3中触发器的本地通知数据?
我正在尝试使用on.(“trigger”)方法更改本地通知中的数据。但是,它使用相同的数据一次又一次地显示相同的通知。这样,我知道通知正在工作,但它不会更改触发器上的数据Javascript 如何更改离子3中触发器的本地通知数据?,javascript,cordova,typescript,ionic-framework,ionic3,Javascript,Cordova,Typescript,Ionic Framework,Ionic3,我正在尝试使用on.(“trigger”)方法更改本地通知中的数据。但是,它使用相同的数据一次又一次地显示相同的通知。这样,我知道通知正在工作,但它不会更改触发器上的数据 Ionic Framework: 3.1.1 Node: 6.10.0 OS: Windows 7 Ionic CLI: 3.0.0 Cordova CLI: 7.0.1 我正在为触发器使用以下代码: ionViewDidLoad() { // Get the JSON data from our ite
Ionic Framework: 3.1.1
Node: 6.10.0
OS: Windows 7
Ionic CLI: 3.0.0
Cordova CLI: 7.0.1
我正在为触发器使用以下代码:
ionViewDidLoad() {
// Get the JSON data from our itemApi
this.itemApi.getItems().then(data => {
this.items = data;
let randomNumber = Math.floor(Math.random() * this.items.length)
// Select the random object an pass it to the oneItem object
this.oneItem = this.items[randomNumber];
});
// --------------------------------------------------------------------------------------
// ---- Function for changing data on trigger
// --------------------------------------------------------------------------------------
// Creates a callback function on the schedule trigger - populates the notification with new data
this.localNotifications.on("trigger", function() {
// Get the JSON data from our itemApi
this.itemApi.getItems().then(data => {
this.items = data;
let randomNumber = Math.floor(Math.random() * this.items.length)
// Select the random object an pass it to the oneItem object
this.oneItem = this.items[randomNumber];
// The notification
let notification = {
id:1,
title: this.oneItem.word,
text: this.oneItem.description,
every: "minute"
};
this.notifications.push(notification);
this.notifications.update(this.notifications);
});
});
}
您知道它为什么不工作吗?您是否签入了console is
trigger
event trigger?我无法在浏览器中触发通知,只能在模拟设备时。。如何检查事件是否已触发?