我很难弄清楚如何在一天中的特定时间设置本地通知并使其每天重复的最新版本的博览会。
"expo": "~40.0.0",
"expo-notifications": "~0.8.2",
function startsTomorowButNotAbleToRepeateEvryDay() {
let tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
tomorrow.setHours(20);
tomorrow.setMinutes(0);
return {
content: {
title: "Time to study v2",
body: "Don't forget to study today!",
},
trigger: tomorrow,
};
}
function repeatsEvryDayButNotPossibleToSetTime() {
const seccondsInADay = 24 * 60 * 60;
return {
content: {
title: "Time to study v2",
body: "Don't forget to study today!",
},
trigger: {
seconds: seccondsInADay,
repeats: true,
},
};
}
Notifications.scheduleNotificationAsync(startsTomorowButNotAbleToRepeateEvryDay());
Notifications.scheduleNotificationAsync(repeatsEvryDayButNotPossibleToSetTime());
如何让通知从明天的特定时间开始并每天重复?
答案 0 :(得分:0)
尝试如下:
const schedule = new Date();
schedule.setHours(19);
schedule.setMinutes(45);
Notifications.scheduleNotificationAsync({
content: {
title: "title txt",
body: 'body text',
},
trigger:{
schedule,
repeats: true,
});