i have an app with a geolocation service.
i map data from the geolocation service to some local storage variables
and i need to invoke the geolocation service every 30 sec and send obtained data to another service.
i tried to add an asset js
code function run_geolocation() {
geolocation.execute({});
setTimeout("run_geolocation()", 15000);
}
/code
then on page load i added coderun_geolocation()/code
and on geolocation success event i added
codevar latitude = localStorage.getItem('latitude');
var longitude = localStorage.getItem('longitude');
var altitude = localStorage.getItem('altitude');
var speed = localStorage.getItem('speed');
var accuracy = localStorage.getItem('accuracy');
var uuid = localStorage.getItem('uuid');
var time = localStorage.getItem('time');
var cdati = 'APPERY'+','+latitude+','+longitude+','+altitude+','+speed+','+accuracy+','+uuid;
alert(time + '-' + cdati);
localStorage.setItem('cdati', cdati);
//invia.execute({});/code
the problem is that the first time i load the page i get 1 alert, but when the geolocation service is executed after 15 sec i get 2 alerts, after more 15 sec i get 3 alerts and so on
what is wrong with my code??
i would like to have just 1 alert (actually /invia.execute({});) each 15 sec
could you help me to understand if i need to use some different way to call every 15 sec the geolocation service?
i took a look to
https://getsatisfaction.com/apperyio/...
https://getsatisfaction.com/apperyio/...
but i didn't understand how to solve my problem