Insomnia-PhoneGap-Plugin
Insomnia-PhoneGap-Plugin copied to clipboard
Not working after long time periods
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.
Without a project that demonstrates this flaw I can’t spend time on this.
`$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();
}`