Reputation: 131
I'm nearly done with a very simple Phonegap application that involves a stopwatch type feature that, when started, needs to run indefinitely until the user stops it, even if they turns their screen off/runs it in the background. I mainly work in javascript, and the only solutions I'm finding require using java and as of now that's a little bit out of my scope. A lot of what I'm finding is 1+ years old though, I'm hoping there's a simplified solution to implementing a service with phonegap, where the entire goal is to keep a single setInterval( , 1000) going when the device is idle. So what would be the most straightforward option for this?
Upvotes: 1
Views: 559
Reputation: 3186
Your best bet is to use the background services plugin.
https://github.com/katzer/cordova-plugin-background-mode
Without that your app will pause when it is set to background. I have read about using AJAX calls to a webserver to keep your app running in the background which will maintain things like setInterval but I have never tried/tested that method.
Upvotes: 1