sioesi
February 23, 2015, 1:35pm
1
I need to perform an action while the device is locked. I have taken the setInvertal function and works well, but at some point, take a few minutes, this function stops running without reason, do not throw any error in the browser nor in GapDebug.
var myInterval = setInterval(function(){update()}, 10000);
Within this function, I make a post to a webservice, checking log into the server, at some point, stop called but somewhere between 2-5 minutes cron, hence runs perfect for front stop calling .
1 Like
Try uesing the $interval module. maybe this helps…
sioesi
February 23, 2015, 3:29pm
3
The problem persists @BioPhoton
what exactly happens when the interval stops? does the phone goes into standby?
could you post your code please?
sioesi
February 23, 2015, 3:47pm
6
@BioPhoton What happens: The device is locked, the action is executed normally for about 2-5 minutes. Then stops working.
var notificacion = $interval(function(){
$scope.notificaciones();
},1000);
$scope.notificaciones = function(){
if(navigator.onLine){
lista_corredores = misCorredoresService.getCorredores();
for (var i = 0; i < lista_corredores.length; i++) {
pid = lista_corredores[i].pid;
$http({method: 'GET', url: URL_ESTADISTICAS+lista_corredores[i].pid+'/splits?pidversion=1&igt='+lista_corredores[i].pid+'&appid='+appId+'&token='+tokenApp})
.success(function(data){
if(data.error){
if(data.error.type=="no_results" && data.error.msg=="No splits found"){
}
}
list_2 = data.list;
pasa = true;
lista = data.list;
lista_anterior = sessionService.get('tiempos_corredor'+lista[0].pid);
ultimo = lista.length;
if(lista_anterior!=null){
ultimo_anterior = lista_anterior.length;
if(lista_anterior == lista[ultimo-1].time){
pasa = false;
}else{
pasa = true;
sessionService.set('tiempos_corredor'+lista[0].pid,lista[ultimo-1].time);
}
console.log("Pasa "+pasa+" corredor "+lista[ultimo-1].pid
console.log(sessionServiceToken.get('token_device')););
Enviar notificacion
console.log("http://dev.lixsys.cl/~nhernandez/pushnotificacion.php?corredor="+lista[ultimo-1].name+"&label="+lista[ultimo-1].label+"&token_device="+sessionServiceToken.get('token_device')); if(pasa){
//Send notification
$http({method: 'GET', url: 'pushnotificacion.php?corredor='+lista[ultimo-1].name+'&label='+lista[ultimo-1].label+'&token_device='+sessionServiceToken.get('token_device')})
.success(function(data){
})
.error(function(){
});
}
}else{
sessionService.set('tiempos_corredor'+lista[0].pid,lista[ultimo-1].time);
$http({method: 'GET', url: 'pushnotificacion.php?corredor='+lista[ultimo-1].name+'&label='+lista[ultimo-1].label+'&token_device='+sessionServiceToken.get('token_device')})
.success(function(data){
})
.error(function(){
});
}
})
.error(function(){
});
}
}
}
Setup logging function that loggs every interesting step in your code with in a scope var.
Key them by timestamp.
And print this out on your phones screen.
sioesi
February 23, 2015, 6:23pm
8
@BioPhoton I got this information in another post and it worked wonders I leave around here in case someone needs it.
thank you very much for your help !!!
sioesi
February 23, 2015, 6:27pm
10
and it was killing me xD, the mistake I make is that no database management, it is a problem to do what I wanted, which was to send notifications but this was solved
Have you encountered any issues with battery life using this plugin? It sounds interesting and could help me solve a big issue… Thanks
sioesi
February 23, 2015, 8:10pm
12
tests and you’ll do tomorrow comment