【发布时间】:2022-08-11 19:40:13
【问题描述】:
如何设置 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: \'???? Reminder!\',
message: \'You have set this reminder\',
date,
repeatType: \'hour\',
});
但不幸的是,通知仅在下午 3.30 显示,重复不起作用...
我正在考虑为全年创建一个时间戳数组并运行 localNotificationSchedule 365 次,但我认为这不是一个好主意......
你有什么建议应该如何在 iOS 和 android 中工作?
标签: android ios react-native push-notification localnotification