简体   繁体   中英

How to implement Schedule local notifications of React native push notification in react native

I am using react-native-push-notifications npm library to implement notifications feature in my app. However, I want to schedule the notifications before 5 miniutes at specific time and I am using PushNotification.localNotificationSchedule so how to implement this pls help, thanks in Advance!

This code is scheduling a notification for 5 minutes before 4:00 PM, 21st January 2023.

import PushNotification from 'react-native-push-notifications'

const time = new Date(2023, 1, 21, 16, 0, 0)
const fiveMinutesBefore = new Date(time.getTime() - 5 * 60 * 1000)

PushNotification.localNotificationSchedule({
  message: "Notification message",
  date: fiveMinutesBefore,
  repeatType: 'minute',
  repeatTime: 5,
  number: 1,
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM