0

What is the proper way to handle continuos tasks like location tracking? If i understood docs correctly, Long-Running Tasks suppose to be started on app going to background.

Can I just run the location tracking (as Long-Running Task) on app start and run it continuously until user will explicitly disable it?

stkvtflw
  • 12,092
  • 26
  • 78
  • 155
  • In case of Location Tracking you can obviously run it continuously but smartly using proper accuracy and filter so that it doesn't require to update so often as running location manager continuously will cause a lot of battery usage. – iphonic Mar 06 '17 at 11:35
  • @iphonic, i know. It was just an example. In fact i'll be dealing with BLE, but this may rise more questions, so i've used Location Tracking for sake of simplicity. So, can i run the long-running task while app in foreground? Is it violating any stupid rules or whatever apple's restrictions? – stkvtflw Mar 06 '17 at 11:37
  • Don't you just want to work with a background thread to deal with these things while your app is in the foreground? – Totumus Maximus Mar 06 '17 at 12:10
  • @TotumusMaximus - probably, that's what i want. I do not know how to do that, as i'm react-native developer. [Docs](https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html) shows only how to start it at quit time. And i haven't found any more useful examples in the web. Do you have one? – stkvtflw Mar 07 '17 at 04:54
  • @stkvtflw: Something like this should probably still work for you. http://stackoverflow.com/questions/7055424/ios-start-background-thread For longrunning tasks when your app goes to the background you can do something like you already read in the apple docs. https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html. If you have more specific requests I could make a less general solution for you, since these examples are pretty basic. – Totumus Maximus Mar 07 '17 at 08:58

0 Answers0