-1

The notification should trigger on the selected date and time.

The notification works in background too but I can just hear the sound and the notification does not appear on the top.
I have tried with the method "ontrigger" but it hasn't worked. What should I do?
Please, help me.

....
var reminderTime = new Date(DateFromTheDataBase[index]);

opt = {
  id         : indexID,
  title      : 'Title',
  message    : data.intent+'\n',
  sound      : '/www/mySound/sound.wav',
  autoCancel : true,
  date   : reminderTime
}
   if(window.plugin && window.plugin.notification.local){ 
    //window.plugin.notification.local.cancelAll();
    window.plugin.notification.local.add(opt);
}

1 Answers1

0

That's how I have solved that problem.
Maybe it can help someone.

I worked with this plugin: "de.appplant.cordova.plugin.local-notification" The data-base-date did not work or trigger

window.plugin.notification.local.add({
    id:      1,
     message: 'wow',
    date:    DateFromDataBase
});



and that is the reason I used window.setInterval() in the method onDeviceready().

function vTime(){

if(CurrentHourID==IDfromDB){
    navigator.notification.alert(storedData.intent,  // message
        null,    // callback
       null,    // title
        'Ok'     // buttonName
     );    
   //LocalNotification
var backgroundID = 1;
var options = {
  id         : backgroundID,
  title      : 'wow',
  message    : storedData.intent,
  //sound      : '/www/sounds/lollipop.wav',
 autoCancel : true
}
if(window.plugin && window.plugin.notification.local){
 window.plugin.notification.local.add(options);
}else{
  alert('**** not ready or no internet connection.');
}
    navigator.notification.vibrate(2000);
    navigator.notification.beep(1);
    }} 
  var currentTime=window.setInterval(function () {
  vTime()}, 1000);