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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -