【问题标题】:Cordova Local Notifications Events not WorkingCordova 本地通知事件不起作用
【发布时间】:2018-08-21 21:29:16
【问题描述】:

我一直在尝试在 Ionic 1 iOS 应用程序上获取本地通知。我已经安装了本地通知插件,我可以安排通知,但回调似乎没有触发。

我可以安排一个通知,当应用程序在后台时它会正确显示:

cordova.plugins.notification.local.schedule({
    text: "Delayed Notification",
    at: new Date(new Date().getTime() + 5*1000)
});

但事件永远不会触发:

cordova.plugins.notification.local.on("click", function(notification) {
    alert("clicked: " + notification.id);
});

【问题讨论】:

    标签: ios ionic-framework cordova-plugins


    【解决方案1】:
    cordova.plugins.notification.local.schedule({
        //add the Id of notification
        id: 1,
        text: "Delayed Notification",
        at: new Date(new Date().getTime() + 5*1000)
    });
    

    【讨论】:

      【解决方案2】:

      我也有类似的问题。

      不确定这是否是一个坏主意,但我不得不将触发回调放在 appmodule 中,然后它就起作用了。

          //Trigger to monitor notifications in case they need to be cleared
          localNotifications.on("trigger", (notification, state) => {
                console.log("Triggering notification (App Module)",notification);            
          });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-09
        • 2013-05-29
        • 2017-03-30
        • 1970-01-01
        • 2017-11-20
        • 2017-12-02
        相关资源
        最近更新 更多