Insomnia-PhoneGap-Plugin icon indicating copy to clipboard operation
Insomnia-PhoneGap-Plugin copied to clipboard

Not working after long time periods

Open fquirogam opened this issue 7 years ago • 2 comments

I used this plugin in an Android tablet that should awake at 8:00 am and sleep at 8:00 pm every day, in a survey app in a local business,everything works right the first 24/48 hours but after that time, the app never makes the tablet awake and keeps the screen locked all time.

The code is inside a setInterval that every minute runs a function that checks the current time and keeps the tablet awaken or lets the tablet sleep.

fquirogam avatar Sep 14 '17 06:09 fquirogam

Without a project that demonstrates this flaw I can’t spend time on this.

EddyVerbruggen avatar Sep 14 '17 08:09 EddyVerbruggen

`$rootScope.compruebaHora=function(){ $scope.date=new Date(); $scope.nowhour=$scope.date.getHours(); $scope.nowminute=$scope.date.getMinutes();

  $rootScope.compruebaActividad();

  if($rootScope.actividad==false){
    $rootScope.screensaver=setTimeout($rootScope.openModal,$rootScope.timeScreenSaver);

    console.log($scope.date.getHours());

    if($scope.nowhour>$scope.inihour && $scope.nowhour<$scope.finhour){
      //awake
      window.plugins.insomnia.keepAwake();
      $scope.despertar();
    } else {
      if(($scope.nowhour==$scope.inihour && $scope.nowminute>=$scope.iniminute) && ($scope.nowhour==$scope.finhour && $scope.nowminute<=$scope.finminute)){
        //awake
        window.plugins.insomnia.keepAwake();
        $scope.despertar();
      } else {
        //sleep
        window.plugins.insomnia.allowSleepAgain();
      }
    }
  } else{
    $scope.stopScreenSaver();
  }`

fquirogam avatar Sep 14 '17 08:09 fquirogam