重复反应本机推送通知中的通知

发布于 2025-01-17 21:44:51 字数 709 浏览 3 评论 0原文

如何设置react-native-push-notification以在每天的特定时间显示本地通知。

因此,在我的移动应用程序中,我有一个屏幕,您可以在应用程序中设置提醒以执行某些操作,并且在选择下午 3:30 后,我想在每天下午 3.30 显示通知。

设置提醒屏幕

我尝试使用 PushNotification.localNotificationSchedule 进行操作,但它无法按预期工作。为了测试视角,假设我想在下午 3.30 显示第一个通知,并每小时向用户显示相同的通知。

PushNotification.createChannel({
    channelId: 'reminders', // (required)
    channelName: 'Task reminder notifications', // (required)
    channelDescription: 'Reminder for any tasks',
  },
  () => {},
);

PushNotification.localNotificationSchedule({
  channelId: 'reminders',
  title: '
              

How to set up react-native-push-notification to show local notification every day at particular time.

So in my mobile application I have a screen when you can set up reminders for doing something in the app and after choose 3:30 PM, I'd like to show notification on everyday at 3.30PM.

set a reminder screen

I tried to do with PushNotification.localNotificationSchedule but it doesn't work as expected. To test perspective let assume that I would like to show first notification at 3.30pm and in every hour show the same notification to the user.

PushNotification.createChannel({
    channelId: 'reminders', // (required)
    channelName: 'Task reminder notifications', // (required)
    channelDescription: 'Reminder for any tasks',
  },
  () => {},
);

PushNotification.localNotificationSchedule({
  channelId: 'reminders',
  title: '???? Reminder!',
  message: 'You have set this reminder',
  date,
  repeatType: 'hour',
});

but unfortunately notification only shows at 3.30PM and repetition is not working...

I was thinking about creating an array of timestamp for whole year and run localNotificationSchedule 365 times but I don't think is a good idea...

Do you have any suggestion how should be working in iOS and android?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

才能让你更想念 2025-01-24 21:44:51

您的重复型应该是“一天”,而不是“小时”。
另外,对于Android,您必须包括称为重复时间的属性。重复时间值通常是一个数字。例如,如果您选择“日”的重复型和1的重复时间,则每天都会收到通知。如果您将重复时间设置为2,它将每两天通知您。

请注意,重复时间属性仅适用于Android。

Your repeatType should be "day" and not "hour".
Also, for android, you have to include the property called repeatTime. The repeatTime value is usually a number. For instance, if you select a repeatType of "day" and repeatTime of 1, you would be getting the notification every day. and if you set the repeat time to 2, it would notify you every two days.

Note, repeatTime property is only for android.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文