1

I am developing an application that should do some action at certain interval that can be defined by the user. I found out that it is not possible to create a service using PhoneGap, so is it possible to run certain code in intervals, like every 5 minutes. Is there possibly another solution that would allow me to do some action at the certain time?

Target platforms are Android & iOS

Edit:
My service should check user's geographic position every 5-15 minutes and send it to the server.

Andrew Lively
  • 2,145
  • 2
  • 20
  • 27
Buksy
  • 11,571
  • 9
  • 62
  • 69

2 Answers2

0

The core of PhoneGap is Cordova, so this answer may be useful:

Cordova scheduling task

Community
  • 1
  • 1
robcalvo
  • 11
  • 1
0

I had a similar requirement where I was supposed to capture the GPS location of a user every 10 seconds.

Here is how I did it :

Every 10 seconds I would capture the geolocation of the mobile phone user and put it in a SQLite database.

I would then run a function every 5 minutes which would batch upload the geolocation data from the SQLite database on device to the server.

I did this to reduce the amount of network calls being made to the server.

This caused a problem when the program went into background mode. To get around that I used the background mode plugin : https://github.com/katzer/cordova-plugin-background-mode