Skip to content

Instantly share code, notes, and snippets.

@AppWerft
Created November 5, 2016 22:09
Show Gist options
  • Save AppWerft/c3dd3b7b2d00da2bd91e034156dcb8d1 to your computer and use it in GitHub Desktop.
Save AppWerft/c3dd3b7b2d00da2bd91e034156dcb8d1 to your computer and use it in GitHub Desktop.
function getCoords() {
Ti.Geolocation.getCurrentPosition(function(e) {
Ti.API.warn(e);
});
}
setInterval(function() {
getCoords();
Ti.App.iOS.scheduleLocalNotification({
alertBody : 'Run time ' + (i / 6).toFixed(1) + ' min.',
date : new Date()
});
i++;
}, 10000);
var i = 0;
var start = new Date().getTime();
/* or 'notification' */
Ti.App.currentService.addEventListener('stop', function() {
Ti.App.iOS.scheduleLocalNotification({
alertBody : 'currentService stopped',
date : new Date()
});
});
Ti.Network.addEventListener("change", function(e) {
var diff = parseInt(((new Date().getTime()) - start) / 1000);
Ti.App.iOS.scheduleLocalNotification({
alertBody : 'Online=' + e.online + " after " + diff + " sec. and "
+ parseInt(i / 10) + "ticks",
date : new Date()
});
});
Ti.App.iOS.scheduleLocalNotification({
alertBody : 'Background service started',
date : new Date()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment