react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
732 stars 281 forks source link

fireDate is not delaying the notification when using with repeats and repeatsComponent #348

Open lclrobert2020 opened 2 years ago

lclrobert2020 commented 2 years ago
const scheduleLocalNotification = () => {
    const getCorrectDate = () => {
      const date = new Date();
      date.setDate(date.getDate() + 1);
      date.setMinutes(date.getMinutes() + 2);
      return date;
    };

    PushNotificationIOS.addNotificationRequest({
      id: 'test',
      title: 'title',
      subtitle: 'subtitle',
      body: 'body',
      category: 'test',
      threadId: 'thread-id',
      fireDate: getCorrectDate(),
      repeats: true,
      repeatsComponent: {
        hour: true,
        minute: true,
      },
    });
     console.log("scheduleLocalNotification called @", Date.now().toLocaleString())
   };

When calling addNotificationRequest with fireDate, repeats and repeatsComponent The first message will not delay until the fireDate is reached, e.g. the above function set the fireDate to be 1 day , 2 minutes later, but the first message is shown after 2 minutes

acintyo commented 2 years ago

Observing the same behavior. It is very confusing. It seems like fireDate only specifies the values for the repeatsComponent. The components which are enabled in the repeatsComponent, their value would be retrieved from the fireDate. This is a step backward in a way but I understand it is as per iOS specification. Please share if there is a way to schedule the notification for a specific date in future.

andrewnguonly commented 2 years ago

This issue might be related to this previously reported issue, #247.