Created
October 1, 2012 19:18
-
-
Save Red-Folder/3813829 to your computer and use it in GitHub Desktop.
Phonegap Service Tutorial - Part2 - Index.html - Cordova 2.x.x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="backgroundService-2.0.0.js"></script> | |
<script type="text/javascript" src="twitterService.js"></script> | |
<script type="text/javascript" > | |
var twitterService = cordova.require('cordova/plugin/twitterService'); | |
document.addEventListener('deviceready', function() { | |
getStatus(); | |
}, true); | |
function getStatus() { | |
twitterService.getStatus( function(r){ startService(r) }, | |
function(e){ alert('An error has occurred in getStatus') }); | |
}; | |
function startService(data) { | |
if (data.ServiceRunning) | |
enableTimer(data); | |
else | |
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 | |
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