Executing Javascript in background using Phonegap

Trevor picture Trevor · Sep 28, 2011 · Viewed 6.9k times · Source

I've created an application that will need to fire Javascript events every "X" minutes. I'm using phone gap build to deploy on Android/iPhone/Blackberry, but I'm of course stuck, as the Javascript timer doesn't fire in the background (when they minimize the app). I was wondering if Phonegap had some sort of ability to fire Javascript events while the app is running in the background.

Or is there ANY way to accomplish this easily across these major phones? I just need to fire an ajax call with the geolocation info from the phones.

Answer

Nico Westerdale picture Nico Westerdale · Dec 15, 2015

Yes you can do it, there's a PhoneGap plugin that does exactly what you need:

PhoneGap + Background.js https://github.com/jocull/phonegap-backgroundjs

Be careful configuring your config.xml