【发布时间】:2018-10-26 19:30:49
【问题描述】:
本地通知无法正常工作(尝试使用 ionic 3 和 4)。 用户可以在应用程序中设置时间并打开或关闭通知。 使用以下代码时,我总是在上午 01:00 收到通知,尽管我已将其设置为 17:30 或其他时间。 我尝试了很多变体,这是最后一个:
const time = setsub.task_reminder_time.split(':');
const now = new Date();
console.log('now is', now);
const pushDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), +time[0], +time[1], 0);
const options = {
id: 1,
title: 'Time to plan your day!',
text: `Hey you! It's time to get productive by planning your day!\nTap here to open DoDay! ????`,
trigger: { firstAt: pushDate, every: ELocalNotificationTriggerUnit.DAY }
};
if (setsub.task_reminder) {
this.notification.requestPermission();
this.notification.schedule(options);
} else {
this.notification.clearAll();
}
time 只是一个包含通知时间的字符串,单位为 HH:mm
我正在使用 iOS 设备进行测试。
【问题讨论】:
标签: ionic-framework notifications ionic3 uilocalnotification ionic4