2

I am using react-native-push-notification library. I want to use the localNotificationSchedule to get a notification every morning at 8:10. So I wrote the code like this, and the notification came until about 3 days, and then the notification does not come. What could be the problem?

      import PushNotification, {Importance} from 'react-native-push-notification';


    const now = new Date();
    const scheduleTime = new Date(
    now.getFullYear(),
    now.getMonth(),
    now.getDate(),
    8, // set hours to 8am
    10, // set minutes to 10
    0, // set seconds to 0
    );

    if (now.getTime() < scheduleTime.getTime()) {
    PushNotification.localNotificationSchedule({
        //... You can use all the options from localNotifications
        title: '오늘의 뉴스를 확인해 보세요!',
        message: '오늘은 어떤 뉴스가 있을까요?', // (required)
        date: scheduleTime,
        allowWhileIdle: true, // (optional) set notification to work while on doze, default: false
        importance: 'high',
        /* Android Only Properties */
        repeatType: 'day',
        channelId: 'local',
        // repeatTime: 1,
    });
    }
user19476497
  • 495
  • 1
  • 10

0 Answers0