【问题标题】:ionic scheduled notification fires immediately after code execution离子预定通知在代码执行后立即触发
【发布时间】:2018-05-02 06:35:10
【问题描述】:

我正在尝试为我的 ionic 项目创建预定通知。我希望通知在活动日期前 2 天发生。当我在设备上测试通知时,通知总是在代码执行后立即触发,而不是在稍后的计划日期触发。

我有以下代码来处理预定通知:

// event date
let eventDate = new Date('2018-06-29T10:04:11.174Z');
// 2 days before event date
let notificationDate = new Date(eventDate.getTime() - 2 * 24 * 60 * 60 * 1000);
// schedule notification
this.localNotifications.schedule({
  text: 'my notification text',
  trigger: {at: notificationDate},
  led: 'FF0000',
  sound: null
});

【问题讨论】:

  • 我也有同样的问题....你解决了吗?
  • 嗨,Grzegorz G,是的,我做到了。请在下面查看我的答案。

标签: cordova ionic-framework notifications


【解决方案1】:

我的问题是我使用的是旧版本的 cordova 本地通知插件,并且该版本中没有 trigger 属性...

触发器属性是在最近的版本中引入的。在此之前,它只接受“at”属性。更新插件后,问题解决了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多