My app is of expo bare workflow
.
Using latest expo & expo notifications.
"expo": "^39.0.0",
"expo-notifications": "~0.7.2",
Problem
Im im trying to schedule a repeat notification on everyday morning 9AM & night 9PM everyday. One Everytime use user opens app, im cancelling all old notifications & scheduling new one, (tried with checking scheduled notification, if not exist schedule new). This seems to be working fine in android simulator, when i install app in phone it triggers notification very rarely or some times nothing for a week. I have just followed given documentation for repeat local notifications. Need help...
Code
// Cancel All notifications
await Notifications.cancelAllScheduledNotificationsAsync();
//9AM notification
await Notifications.scheduleNotificationAsync({
identifier: 'morning-1',
content: {
title: `Good Morning!`,
subtitle: 'Greetings',
body: `Have a great day`,
sound: true,
color: "#ffffff",
data: {
to: 'new-log'
}
},
trigger: {
hour: 9,
minute: 0,
repeats: true
}
});
//9PM notification
await Notifications.scheduleNotificationAsync({
identifier: 'night-notification',
content: {
title: `Good Night :)`,
subtitle: 'Have a great sleep :D',
body: `Have a great sleep :D',
sound: true,
data: {
to: 'new-log'
},
color: "#000000" },
trigger: {
hour: 21,
minute: 0,
repeats: true
}
});
But it doesn't trigger notifications properly, what i observed, it will show notifications like 3 days once or weekly once or sometimes nothing. it is not trigger on given time at all.
Update Apparently its battery optimization of UIs like MIUI, Oxygen OS causing notification not to appear when device is in doze mode. The workaround which i found is to ask user to turn off battery optimization for the app. But i feel notifications should override dozemode regardless of battery optimization...