This is what I do for repeat notifications
await LocalNotifications.schedule(
[
{
id: notification.id,
channelId: notification.sound,
title: notification.title,
body: notification.body,
schedule: {
on: {
weekday: notification.weekday,
hour: notification.hour,
minute: notification.minute,
second: notification.second
},
allowWhileIdle: true
}
}
]
)
This is for single notifications
await LocalNotifications.schedule(
[
{
id: notification.id,
channelId: notification.sound,
title: notification.title,
body: notification.body,
schedule: {
at: notification.time,
allowWhileIdle: true
}
}
]
)
I know they are being scheduled properly, because they will always trigger right on time as long as the phone is active (the app doesn’t have to be open or even running). It’s only when the phone is idle they don’t trigger, and when I check all pending notifications, they are in there.
I’ve also channels already setup, so I know those specific channels exist. These are all of them:
const notificationChannels: Channel[] = [
{
id: 'Alarm1',
name: 'Alarm1',
importance: 5,
sound: 'alarm_1.wav',
visibility: 1,
vibration: true
},
{
id: 'Alarm2',
name: 'Alarm2',
importance: 5,
sound: 'alarm_2.wav',
visibility: 1,
vibration: true
},
{
id: 'Alarm3',
name: 'Alarm3',
importance: 5,
sound: 'alarm_3.wav',
visibility: 1,
vibration: true
},
{
id: 'Alarm4',
name: 'Alarm4',
importance: 5,
sound: 'alarm_4.wav',
visibility: 1,
vibration: true
},
{
id: 'Alarm5',
name: 'Alarm5',
importance: 5,
sound: 'alarm_5.wav',
visibility: 1,
vibration: true
},
{
id: 'Alarm6',
name: 'Alarm6',
importance: 5,
sound: 'alarm_6.wav',
visibility: 1,
vibration: true
},
{
id: 'Alarm7',
name: 'Alarm7',
importance: 5,
sound: 'alarm_7.wav',
visibility: 1,
vibration: true
},
{
id: 'Alarm8',
name: 'Alarm8',
importance: 5,
sound: 'alarm_8.wav',
visibility: 1,
vibration: true
},
{
id: 'Notification1',
name: 'Notification1',
importance: 5,
sound: 'notification_option_1.wav',
visibility: 1,
vibration: true
},
{
id: 'Notification2',
name: 'Notification2',
importance: 5,
sound: 'notification_option_2.wav',
visibility: 1,
vibration: true
},
{
id: 'Notification3',
name: 'Notification3',
importance: 4,
sound: 'notification_option_3.wav',
visibility: 1,
vibration: true
}
]