This is a migrated thread and some comments may be shown as answers.

navigator.geolocation.watchPosition in the background

5 Answers 714 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mat-Moo
Top achievements
Rank 1
Mat-Moo asked on 02 Mar 2015, 04:49 PM
Quick overview, I'm doing a 54km walk for charity - http://toejam.rocks in several weeks time, and to help drive and engage I wanted to add a geolocation tracker onto the website., I've been through several of the samples and get all the data correctly. I've provision my iphone and created a build which I've installed and it works perfectly... as long as the phone is on and the app is currently on the screen. As soon as I switch apps or the phone goes to sleep, I get no more data (ajax call sending it to my server) :( any clues? I've got background goe-location on, not sure what else I can/should do?

5 Answers, 1 is accepted

Sort by
0
Zdravko
Telerik team
answered on 05 Mar 2015, 08:17 AM
Hi Matthew,

I am not sure whether you are using this geolocation plugin that keeps the service alive in background is you may want to try it.
Another solution you can try is to use the Background plugin which prevents your app from sleeping while in background.
Hopefully any of them will let you achieve your aim.

Regards,
Zdravko
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Mat-Moo
Top achievements
Rank 1
answered on 05 Mar 2015, 10:14 PM
I'm just using the one in AppBuilder, v 0.3.11 and have enabled background mode for Location (Well think so, how do you know if an Icon is on or off??!!). DO you think I should abandon that and import one of the others?
0
Zdravko
Telerik team
answered on 10 Mar 2015, 12:29 PM
Hello Matthew,

Thank your for the reply.
Background setting is enabled when highlighted in blue. Here is what Apple says about the mode:

Enabling this mode does not prevent the system from suspending the app, but it does tell the system that it should wake up the app whenever there is new location data to deliver. Thus, this key effectively lets the app run in the background to process location updates whenever they occur.

However, I think that you should use the Background plugins (especially the one that keeps whole app alive) I posted and experiment with them since you have troubles sending data in background only.

Regards,
Zdravko
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Mat-Moo
Top achievements
Rank 1
answered on 10 Mar 2015, 09:51 PM
Got the geo location background plugin working, I would say the only downside is that it only works in the background! SO I need my original code and that code, slightly odd, but hopefully enough to get what I need done.
0
Zdravko
Telerik team
answered on 13 Mar 2015, 02:08 PM
Hi Matthew,

Thank you for your reply.
I have never tested it but it seems a step forward.
The plugin seems highly configurable so maybe with some more adjustments will do the job.

I found this note :
NOTE: The plugin includes org.apache.cordova.geolocation as a dependency. You must enable Cordova's GeoLocation in the foreground and have the user accept Location services by executing #watchPosition or #getCurrentPosition.

Maybe you will have to keep your foreground logic as you have already determined.

Regards,
Zdravko
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
General Discussion
Asked by
Mat-Moo
Top achievements
Rank 1
Answers by
Zdravko
Telerik team
Mat-Moo
Top achievements
Rank 1
Share this question
or