[SOLVED] How to LocalNotifications Schedule right way?


#1

Hi there!
Im now wondering how to make automatic generation of localNotifications for medicine app.
I have to generate notifications by users entered HOW MANY TIMES, STARTING WHEN, INTERVAL
please help my by code example how to correctly generate\cancel such notifications.

Example workflow:
User have to dring some mixture 3 times per day, he chooses
[starting time - 08:00 a.m.]
[how many times - 3]
[Interval - 2 hours]
[What medicine - Mixture]

-> On Submit

need to generate something like
var aaa = ’ 08:00 a.m’;
$cordovaLocalNotification.schedule([{
title: “Take your medicine”,
text: “Mixture”,
at: aaa,
every:‘day’,
sound: “file://sounds/reminder.mp3”,
icon: “file://img/logo.png”,
data: {
goto:“application.statex”,
drug_id:“mixture”,

}
},
{
title: "Take your medicine",
text: "Mixture",
at: aaa+2 hours,
every:'day', 
sound: "file://sounds/reminder.mp3",
icon: "file://img/logo.png", 
data: { 
goto:"application.statex",
drug_id:"mixture",

}
},
{
title: "Take your medicine",
text: "Mixture",
at: aaa +2hours*2 ,
every:'day', 
sound: "file://sounds/reminder.mp3",
icon: "file://img/logo.png", 
data: { 
goto:"application.statex",
drug_id:"mixture",

}
}]);

Very appreciate your time and help