简体   繁体   English

如何在react native中实现React native推送通知的Schedule local notifications

[英]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.我正在使用 react-native-push-notifications npm 库在我的应用程序中实现通知功能。 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!但是,我想在特定时间将通知安排在 5 分钟之前,并且我正在使用 PushNotification.localNotificationSchedule 所以如何实现这个请帮助,在此先感谢!

This code is scheduling a notification for 5 minutes before 4:00 PM, 21st January 2023.此代码安排在 2023 年 1 月 21 日下午 4:00 之前的 5 分钟发出通知。

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,
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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