navigator.geolocation.watchPosition in the background

6 posts, 0 answers
  1. Mat-Moo
    Mat-Moo avatar
    103 posts
    Member since:
    Nov 2012

    Posted 02 Mar 2015 Link to this post

    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?
  2. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 05 Mar 2015 Link to this post

    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.

     
  3. Mat-Moo
    Mat-Moo avatar
    103 posts
    Member since:
    Nov 2012

    Posted 05 Mar 2015 in reply to Zdravko Link to this post

    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?
  4. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 10 Mar 2015 Link to this post

    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.

     
  5. Mat-Moo
    Mat-Moo avatar
    103 posts
    Member since:
    Nov 2012

    Posted 10 Mar 2015 Link to this post

    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.
  6. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 13 Mar 2015 Link to this post

    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.

     
Back to Top