首页 > 解决方案 > 离子中的本地通知

问题描述

这是我的代码

this.platform.ready().then(() => {
      this.localNotifications.schedule({    // ionic local notification native plugin.
        title: 'Welcome',
        text: 'xxxxxxxxxx',
        at: new Date(new Date().getTime() + 1000)
      })
    })

使用at:变量时,我得到的错误是

'{ title: any; 类型的参数 文本:字符串;在:日期;}' 不可分配给“ILocalNotification |”类型的参数 本地通知”。对象字面量只能指定已知属性,而 'at' 不存在于类型 'ILocalNotification | 本地通知”。

我想在 1 秒后提示通知。我该怎么做 ?

标签: ionic-frameworkionic2ionic3ionic-native

解决方案


您的选项对象与本地通知选项不匹配,请查看此链接https://ionicframework.com/docs/native/local-notifications/。在这里您可以找到所有选项。对于计划 1 秒延迟本地通知,您可以像这样修改代码。

 this.localNotifications.schedule({
   title: 'Welcome',
   text: 'xxxxxxxxxx',
   trigger: {at: new Date(new Date().getTime() + 1000)},
   });

希望你能找到你的解决方案。


推荐阅读