Skip to content

Instantly share code, notes, and snippets.

@Red-Folder
Created September 24, 2012 20:44
Show Gist options
  • Save Red-Folder/3778262 to your computer and use it in GitHub Desktop.
Save Red-Folder/3778262 to your computer and use it in GitHub Desktop.
Phonegap Service Tutorial - Part2 - Index.html
<script type="text/javascript" src="backgroundService.js"></script>
<script type="text/javascript" src="twitterService.js"></script>
<script type="text/javascript" >
document.addEventListener('deviceready', function() {
getStatus();
}, true);
function getStatus() {
window.plugins.twitterService.getStatus( function(r){ startService(r) },
function(e){ alert('An error has occurred in getStatus') });
};
function startService(data) {
if (data.ServiceRunning)
enableTimer(data);
else
window.plugins.twitterService.startService( function(r){ enableTimer(r) },
function(e){ alert('An error has occurred in startService') });
}
function enableTimer(data) {
if (data.TimerEnabled)
alert('Service started and timer enabled');
else
window.plugins.twitterService.enableTimer( 60000,
function(r){ /* All running, no action */ },
function(e){ alert('An error has occurred in enableTimer') });
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment