反应本机localNotificationSchedule在循环中不适用于多个日期和时间

时间:2019-06-18 06:26:39

标签: react-native react-native-ios react-native-push-notification

我尝试调用localNotificationSchedule函数在forEach循环中在不同时间显示不同的消息,它适用于android,但在ios中仅触发了循环中的最后一个通知。

有什么想法吗?

forEach((id) => {

      if (!MainStore.pushNotificationsActive[id]) {
        const notification = MainStore.notifications[id]
        console.log('Currently setting', notification)
        const messageToDisplay = notification.reminder_message.includes('[Name]') ? notification.reminder_message.replace('Hi [Name], ', '') : notification.reminder_message

        if (MainStore.userProfile.field_withdrawn == true) {
          console.log('======notifications stoped======')
          PushNotification.cancelAllLocalNotifications()
        } else {
          console.log('=======notifications start=====')
          const date = Date.parse(notification.reminder_start_date)

          PushNotification.localNotificationSchedule({
            id: String(id),
            message: messageToDisplay,
            playSound: true,
            date: new Date(date)
          })
          MainStore.pushNotificationsActive[id] = true
        }
      }
    })

1 个答案:

答案 0 :(得分:0)

对不起,我找到了一个解决方案,iOS最多允许60条本地日程表通知,当我将通知数减少到60条时,它可以工作。