首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >react-native-firebase scheduleNotification

react-native-firebase scheduleNotification
EN

Stack Overflow用户
提问于 2018-06-08 00:45:23
回答 1查看 594关注 0票数 2

我正在尝试安排7个不同的通知,每天与以下代码。

代码语言:javascript
复制
    const interval = 1440;

    for (let i = 0; i < 7; i++) {
            const notification = new firebase.notifications.Notification()
                  .setNotificationId(notifyId + i.toString())
                  .setTitle('Quote of the Day')
                  .setBody('today is a beautiful day')
                  .setData({
                    dailyQuote:'today is a beautiful day'
                  });

            const date = new Date();
            date.setMinutes(date.getMinutes() + (i * interval));

            const schedule = {
                fireDate: date.getTime(),
                repeatInterval: 'day',
            };

    firebase.notifications().scheduleNotification(notification, schedule);
    }

然而,即使fireDate恰好设置在1440分钟(1天)之后,通知也会同时触发。

有人能帮上忙吗?谢谢!

EN

回答 1

Stack Overflow用户

发布于 2019-07-27 22:41:30

将repeatInterval更改为'week‘对我来说很管用。

代码语言:javascript
复制
const schedule = {
        fireDate: date.getTime(),
        repeatInterval: 'week',
      };
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50746405

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档