How to track the device location (iOS and Android) device using Phonegap -


i know when user arrives or leaves location. trying using wireless network (check mobile devices), couldn't several reasons.

1) needed real time updates or every 1 - 5 min of information devices connected , devices have disconnected.

2) had high ping pc iphone on same network (still don't know why).

now want using geolocation phonegap application (running in background) suspended on ios or running in background in android.

any appreciated.

the first thing creating phonegap app receives location updates while running in background entirely possible, not trivial. i've done myself , released apps on both android , ios platforms.

if need accurate , regular position updates, i'd suggest using gps receiver on target devices. in phonegap, can setting "highaccuracy" flag when requesting position updates. watchposition() function deliver new position information , when device receives updates gps receiver, use this:

navigator.geolocation.watchposition(successcallback, errorcallback, {   enablehighaccuracy: true,   timeout: 10000,   maximumage: 0 }); 

see phonegap geolocation api documentation more details (note permissions required make work on android , ios).

to keep app running in background on either android or ios need setup respective native development environments: eclipse android, xcode ios. not able use phonegap build because custom settings needed in both cases make work. see phonegap platform guides how this.

to keep app running in background on android, either need write custom android service, or did , use phonegap plugin acquire "partial wakelock" (see here) keep app running in background , receive position updates while screen off. note original version of plugin out-of-date , doesn't work more recent versions of phonegap, , doesn't support partial wakelocks. however, i've updated , extended own use: can find source code in answer this question.

to keep app running in background on ios, need things differently; don't need plugin, project setting.

you can either manually edit project .plist , add key “uibackgroundmodes” key value of “location” or, project open in xcode, add "required background modes" key value of "app registers location updates". cause ios trigger js callback function have registered watchposition() each time location update received. see here more ios project keys , background modes.

hope helps!


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -