dear All I am facing some issue on ionic capacitor local notification
the notification is working fine if i schedule only one notification inside notification array. but if i schedule multiple notification, it is not working
here is the code bellow
[
{
"title": "Scheduled Notification",
"body": "This is your 5:00 notification",
"id": 1,
"schedule": {
"at": "2024-07-18T00:28:00.000Z"
},
"sound": null,
"attachments": null,
"actionTypeId": "",
"extra": null
},
{
"title": "Scheduled Notification",
"body": "This is your 6:00 notification",
"id": 2,
"schedule": {
"at": "2024-07-18T00:30:00.000Z"
},
"sound": null,
"attachments": null,
"actionTypeId": "",
"extra": null
},
{
"title": "Scheduled Notification",
"body": "This is your 7:00 notification",
"id": 3,
"schedule": {
"at": "2024-07-18T01:30:00.000Z"
},
"sound": null,
"attachments": null,
"actionTypeId": "",
"extra": null
},
{
"title": "Scheduled Notification",
"body": "This is your 8:00 notification",
"id": 4,
"schedule": {
"at": "2024-07-18T02:30:00.000Z"
},
"sound": null,
"attachments": null,
"actionTypeId": "",
"extra": null
}
]
const permission = await LocalNotifications.requestPermissions();
if (permission.display === 'granted') {
LocalNotifications.schedule({notifications}).then(data=>{
console.log('schedule successfull: ', data);
});
LocalNotifications.addListener('localNotificationReceived', (notification) => {
console.log('Notification recieved', notification);
});
LocalNotifications.addListener('localNotificationActionPerformed', (notification) => {
console.log('Notification action performed', notification);
});
} else {
console.error('Notification permission not granted.');
}
with this, the notification is not coming. but notification is working if i set only one notification like this
const permission = await LocalNotifications.requestPermissions();
if (permission.display === 'granted') {
LocalNotifications.schedule({
notifications: [
{
channelId: '1',
id: 1,
title: 'Water Reminder',
body: 'Drink Water',
largeIcon: 'res://drawable/drop',
sound: 'fillwater.wav',
extra: { type: 'w_reminder' },
schedule: {
at: new Date(Date.now()+15000),
allowWhileIdle: true,
repeats: true,
every: 'day'
},
}
]
});
LocalNotifications.addListener('localNotificationReceived', (notification) => {
console.log('Notification recieved', notification);
});
LocalNotifications.addListener('localNotificationActionPerformed', (notification) => {
console.log('Notification action performed', notification);
});
} else {
console.error('Notification permission not granted.');
}
here is the permission section from AndroidManifest.xml
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
please help