我正在安排按用户设置的时间重复(天)本地通知。 我想为用户提供一个选项,以便他/她可以在周末(周六、周日)禁用这些通知。 是否可以 ?如果是,请引导我走向正确的方向。
我正在使用这个library这是我用来安排本地通知的代码。
PushNotification.localNotificationSchedule({
message: 'good morning',
date: date,
smallIcon: "ic_notification",
color: "#3591EC",
repeatType:'day',
});
最佳答案
按照 Chris Allwein 的建议我没有取消每日重复通知,而是根据用户选择安排了每周重复通知。我就是这样做的。希望它对某人有帮助。
let days=['Monday','Tuesday','Wednesday','Thursday','Friday'];
for(let i=0; i<days.length; i++){
let date = moment(days[i],"dddd");
Notification.schedule(message,date);
}
并在Notification.schedule()
中我执行了以下操作
schedule(message, date){
let date = new Date(date);
PushNotificationIOS.scheduleLocalNotification({
fireDate: date.getTime(),
alertBody: message,
repeatInterval:'week'
});
}
关于javascript - 取消周末重复本地通知 [React Native],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45014580/