I have integrated the Ionic 3 local notification plugin into my project by running these commands:
ionic cordova plugin add cordova-plugin-local-notification
npm install --save @ionic-native/local-notifications
All necessary dependencies have been added to my constructor.
The code snippet is as follows:
let year = new Date().getFullYear();
let month = new Date().getMonth();
let day = new Date().getDate();
let time1 = new Date(year, month, day, 10, 00, 0, 0);
let time2 = new Date(year, month, day, 12, 00, 0, 0);
this.localNotifications.schedule([
{
id: 1,
title: 'My first notification',
text: 'First notification test one',
trigger: { at: new Date(time1) },
data: {"id": 1, "name": "Mr. A"}
},
{
id: 2,
title: 'My Second notification',
text: 'Second notification on 12 pm',
trigger: { at: new Date(time2) },
data: {"id": 2, "name": "Mr. B"}
}
]);
While this setup works fine for triggering notifications on app start for the current day, I now aim to schedule a notification every day at the specified time.
It's important to note that I specifically intend to use local notifications and not push notifications.