I have the same issue as many others here: I want to build a daily notification on which time is selected in frontend and want to execute a daily notification at the same time every day. I tried the repeats: true and every: 'day' here, but it didn't work for me. I tried this and searched everywhere.
I'm Using Ionic with angular on that am Using the Local Notification capacitor plugin.
Look for my code below.
import { LocalNotifications } from '@capacitor/local-notifications';
async setAlarm() {
const now = new Date();
const alarmDate = new Date(this.alarmTime);
const alarmTime = new Date();
alarmDate.setFullYear(now.getFullYear(), now.getMonth(), now.getDate());
if (alarmDate <= now) {
alarmDate.setDate(alarmDate.getDate() + 1);
}
await LocalNotifications.schedule({
notifications: [
{
title: 'Alarm',
body: 'Time to wake up!',
id: 1,
schedule: {
at: new Date(this.alarmTime),
repeats: true,
every: 'day',
},
actionTypeId: '',
extra: null,
},
],
});
alert('Alarm set for ' + alarmDate.toLocaleTimeString() + '.');
}
The code above only sends out notifications at the user-selected times, but I need them sent out every day at the same time. Let me know if you have any references or suggestions.
I have tried this and searched everywhere. I'm Using Ionic with angular on that am Using the Local Notification capacitor plugin.
I need Notification to sent out every day at the same time which user choosen. Let me know if you have any references or suggestions.