Is it possible to build an app with phonegap build, that runs some background process(like every few minutes whether app opened or not)

  • 1
  • Question
  • Updated 4 years ago
Is it possible to build an app with phonegap build, that runs some background process(like every few minutes whether app opened or not) .
Photo of Bhaskar Rao

Bhaskar Rao

  • 9 Posts
  • 0 Reply Likes

Posted 8 years ago

  • 1
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
On Android and iOS, your app should continue to run in the background after it is closed by clicking the home button or back button (unless the user explicitly kills the app). So you should still be able to run javascript, and use a JS timeout to intermittently run code.
Photo of Muthuraj T

Muthuraj T

  • 10 Posts
  • 0 Reply Likes
Hi Ryan,
Will JS timeout work like Android Background service? If user closes the app JS will not run, right?
Photo of chetan

chetan

  • 2 Posts
  • 0 Reply Likes
Hi Ryan,

Will it be possible to keep running background service even after user kill the app explicitly ?

actually i want to make service which will be running in background for infinite time.
even after user kills the app.

i have implemented plugin from below url :

https://github.com/katzer/cordova-plu...

but it will kills the service as soon as the app was killed.
Photo of Adam Joseph Looze

Adam Joseph Looze

  • 34 Posts
  • 0 Reply Likes
I am currently working on the same thing. It is a monitoring system for parents. If you have figured this out, i would appreciate an email greatly. aklooze@hotmail.com
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
How do you want the user to be able to stop the service?
(Edited)
Photo of chetan

chetan

  • 2 Posts
  • 0 Reply Likes
Hi Petra,

Thank you so much for the reply.

Actually i want to make service which will run as daemon(user does not allow to stop the service from app).

i want to get geo location and store the same in database on every 5 to 10 minute.

for that i want to make service which will run in background and store user location in database.

And i want to implement same in Android/IOS7/blackberry10 and in windows phone if possible.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Please, allow me to give a personal opinion, first: I would be hesistant to accept an app that implements a "secret service" that can not be stopped and that tracks the whereabouts of the user.

Now, for Phonegap: PGB is a service that allows developers to create apps based on a webview. This means, that PGB expects html/javascript/graphis/css only. Within this app, you can make use of plugins...but it will still be an app with its webview.

As long as the app is active or 'stand-by', you can use the Geolocation plugin to implement the watchPosition() method and keep track of the user's position. You can use any persistent method (localStorage, indexedDB) to save the data for later use by the same app.
PGB allows building of apps for Android, iOS and WinPhone.