挑战是:如何在新的博览会 API 中设置通知的开始日期。在旧 API(今天已弃用)中这是可行的,但我在新的 doc
中看不到解决方案例如:从用户指定的日期(例如 1 月 12 日)开始,每隔 2 天设置一次通知。
我经历了这些类型
export type SchedulableNotificationTriggerInput =
| DateTriggerInput
| TimeIntervalTriggerInput
| DailyTriggerInput
| WeeklyTriggerInput
| CalendarTriggerInput;
但到目前为止还没有成功。
答案 0 :(得分:0)
据我所知,您应该可以这样设置开始日期:
const dateString = "21/01/2021"; // Jan 21
const trigger = new Date(dateString);
trigger.setMinutes(0);
trigger.setSeconds(0);
Notifications.scheduleNotificationAsync({
content: {
title: 'Happy new hour!',
},
trigger,
});
您应该使用 trigger.setMinutes
和 trigger.setSeconds
设置特定日期的特定小时。