Katzer Local notification plugin
I can set and use single notification.
According to the description mutiple notification can be set using
cordova.plugins.notification.local.schedule([{
id: 1,
text: "Multi Notification 1",
sound: isAndroid ? 'file://sound.mp3' : 'file://beep.caf',
data: { secret:key }
},{
id: 2,
title: "Local Notification Example",
text: "Multi Notification 2",
icon: "http://sciactive.com/pnotify/includes/github-icon.png"
}]);
But my notifications are dynamic and it's total number is also dynamic. For example say total
is the variable where total number of notification is saved. total
can be 1 or 10 or 30 etc.
Now how to build the array for it?? I tried like this
for(i=0;i<total;i++)
{
// ......... calculate bhhour,vmin,vsec etc. ............. //
time_for_noti=new Date(year,month-1,parseInt(i),vhour,vmin,vsec);
arr[i]=' id: app_'+i+' , title: ' +i+' - '+time_for_noti+',text: app alarm.,sound: null,at : '+time_for_noti+' ';
}
And then
cordova.plugins.notification.local.schedule(arr);
App hangs for some time say 15-20 sec, then crashes. Then I tried brackets '{}' before and after the strings.
for(i=0;i<total;i++)
{
// ......... calculate bhhour,vmin,vsec etc. ............. //
time_for_noti=new Date(year,month-1,parseInt(i),vhour,vmin,vsec);
arr[i]='{ id: app_'+i+' , title: ' +i+' - '+time_for_noti+',text: app alarm.,sound: null,at : '+time_for_noti+' }';
}
Again same result. App crashes after 10-15 sec from schedule line's execution. I also tried making a huge string manually something like
ex='[{ id:........} , {..........}]';
And then
cordova.plugins.notification.local.schedule(ex);
It crashes the app immediately after this line's execution. I know it's a dumb idea, but desperate times.
What I'm doing wrong? How to achive this multiple alarm dynamically for total 20-40 notification? What I'm missing?