Search code examples
react-nativeschedulerlocalnotificationreact-native-push-notification

React Native Scheduled Local Notifications showing scheduled time instead of current time in notification tray


I have scheduled a local notification by adding 1 day as scheduled date. When receiving notification it shows notification arrival date as 1 day ago which is the scheduler added date, instead of current time as(now). Anyway to fix this?


Solution

  • My buildAndroidNotification function has attribute when attribute as follows,

    when: new Date().getTime()

    instead of current date object it needed to pass scheduled date's time value, if using moment.js

     let timeStampMoment = moment(scheduleDate, "MM-DD-YYYY Z").valueOf();
    

    and set,

      when: timeStampMoment