[英]React Native Push Notifications not coming in the notification pane in Android
[英]Repeating Notifications in React Native Push Notification
如何设置 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 工作?
您是否尝试过重复类型:“天”? https://github.com/zo0r/react-native-push-notification
您的 repeatType 应该是“day”而不是“hour”。 此外,对于 android,您必须包含名为 repeatTime 的属性。 repeatTime 值通常是一个数字。 例如,如果您 select 的 repeatType 为“day”且 repeatTime 为 1,则您每天都会收到通知。 如果您将重复时间设置为 2,它会每两天通知您一次。
请注意,repeatTime 属性仅适用于 android。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.