I try to use @capacitor/local-notifications
with Ionic 7 and React. For iOS the notifications work perfectly, but for Android the notifications arrive irregular. Sometimes the message arrives 10min too late, sometimes even 70min too late. It seems correlated with the screen state: when I wake up the phone, the notifications arrives a little later.
I added the SCHEDULE_EXACT_ALARM
permission.
I use the allowWhileIdle: true
attribute.
My code:
async function createLocalNotifications() {
const check = await LocalNotifications.checkPermissions(); // {receive: "granted"}
const res = await LocalNotifications.requestPermissions(); // {display:"granted"}
if (res.display === "granted") {
LocalNotifications.createChannel({
id: "1",
name: "channel_name",
description: "channel_description",
})
.then(() =>
LocalNotifications.schedule({
notifications: [
{
channelId: "1",
id: 1,
title: `Daily notification`,
body: "at 16:00",
schedule: {
on: { hour: 16 },
allowWhileIdle: true,
},
},
],
})
)
}
}
What could be the problem?