ios icon indicating copy to clipboard operation
ios copied to clipboard

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

Open lclrobert2020 opened this issue 3 years ago • 3 comments

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

lclrobert2020 avatar Jan 17 '22 08:01 lclrobert2020

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.

acintyo avatar Jan 17 '22 18:01 acintyo

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

andrewnguonly avatar Jan 21 '22 06:01 andrewnguonly