var notifications = new Array();
//función que envíanotificaciones
function sendNotification (title, options) {
  

    sendingNotification = function (title, options) {
      // Gecko < 22
      var notification = navigator.mozNotification
               .createNotification(title, options.body, options.icon);
      notification.show();

      notifications.push(notification);


      notification.onclick = function() {   
        openTheApp();
        window.location.reload();
      }

      if( options.type == 'validate' ){
        //abrir popup avisando de que debe de validar
        //hacer logout en 20 segundos
        
        $.ajax({
          type: 'POST',
          url: 'http://dailes.w.pw/resend_validate_email_by_token',
          timeout: 10000,
          data: { token : localStorage.userToken },
          dataType: 'json',

          success: function(resp) {

            if( resp == '1'){
              
                localStorage.userLogin = 0;
                localStorage.userToken = '';
                localStorage.allDailies =JSON.stringify( new Array() );
                localStorage.activeDailies = JSON.stringify( new Array() );
                localStorage.points = JSON.stringify( new Object() );
                localStorage.dailyAlarm = '';
                localStorage.btnAnswerStatus = 0;
                localStorage.btnDailyStatus = 0;
                localStorage.counterReviewAlarm = 0;
                removeAlarmAll();
                window.location.href = '#/login';

            }
          },
          complete: function(){}
        });

        

      }
      
      notification.onclose = function() { 
        console.log('closed'); 
      }
      
    };


  
  sendingNotification(title, options);
 

};