Getting user location when app is in background. IOS -


i'm developing app works in background user's location , send server using http requests. first intention user's location every n minutes, after alot of research , trial, gave since ios kills background tasks after 3 minutes.

then tried working on monitoringsignificantlocationchanges, inaccurate location updates due cell tower usage ruins purpose of app.

a solution of following appreciated:

  1. getting user's location in background every n minutes infinitely.
  2. getting user's location in background on significantlocationchanges high accuracy(using gps)
  3. any other background solution high accuracy results.

this works me, use cllocationmanagerdelegate, register updates on didupdatelocations , in app delegate

- (void)applicationdidbecomeactive:(uiapplication *)application {     [_locationmanager stopmonitoringsignificantlocationchanges];     [_locationmanager startupdatinglocation]; } 

i start updating location, key me, when app goes background switch significant location changes app doesn't drain batter this:

- (void)applicationdidenterbackground:(uiapplication *)application {     [_locationmanager startmonitoringsignificantlocationchanges]; } 

in didupdatelocations, can check

bool isinbackground = no; if ([uiapplication sharedapplication].applicationstate == uiapplicationstatebackground) {     isinbackground = yes; } 

and start task in background report location example

if (isinbackground) {     [self sendbackgroundlocationtoserver:self.location]; } 

and start task, hope helps.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -