【发布时间】:2018-09-26 09:47:58
【问题描述】:
我已使用以下命令将 Ionic 3 本地通知插件添加到我的项目中:
ionic cordova plugin add cordova-plugin-local-notification
npm install --save @ionic-native/local-notifications
我在构造函数上添加了所有依赖项。
我的代码是:
let year = new Date().getFullYear();
let month = new Date().getMonth();
let day = new Date().getDate();
let time1 = new Date(year, month, day, 10, 00, 0, 0);
let time2 = new Date(year, month, day, 12, 00, 0, 0);
this.localNotifications.schedule([
{
id: 1,
title: 'My first notification',
text: 'First notification test one',
trigger: { at: new Date(time1) },
data: {"id": 1, "name": "Mr. A"}
},
{
id: 2,
title: 'My Second notification',
text: 'Second notification on 12 pm',
trigger: { at: new Date(time2) },
data: {"id": 2, "name": "Mr. B"}
}
]);
它适用于当天应用启动,但我想每天在指定时间发送通知。
我特别想要本地通知,而不是推送通知。
【问题讨论】:
标签: angular cordova typescript ionic-framework ionic3