0

If user changes their Location settings

from ‘always’ to ‘when in use’ .

And doesn’t go back to the application. Sometimes I see the blue bar and sometime I don’t see it.

If blue bar doesn’t show then my app can get removed from memory.

The only thing I do in my didChangeAuthorization method is that if it’s not restricted, denied, .notDetermined then I call startUpdatingLocation().

I know I can't make the app startUpdatingLocation while it's in background.

But shouldn't I be able to continue that when I do it change from 'Always' to 'when in use'?! Is this a behavior I have no control over it ?

mfaani
  • 33,269
  • 19
  • 164
  • 293
  • To continue location service in background, Apple's [doc](https://developer.apple.com/documentation/corelocation/cllocationmanager/1620562-requestwheninuseauthorization) says you need to enable "background location updates in the Capabilities tab of your Xcode project". Pls check it. – beshio Oct 01 '18 at 23:36
  • I've already done that. – mfaani Oct 02 '18 at 01:59
  • Ok, sorry for not being helpful... – beshio Oct 02 '18 at 02:34
  • you can take a look at my own answer... – mfaani Oct 03 '18 at 15:50

1 Answers1

1

After more rounds of testing. With great confidence I can say:

If you switch to Never then the OS will call stopUpdatingLocation in 10 seconds or less.

So if before you reach the 10 seconds you switch to 'when in use' then you'd see the blue bar and you're all good.

If you wait for 10-20 seconds then you would no longer see the blue bar because the stopUpdatingLocation is called. To start tracking again you must bring the app in foreground and then it would start updating your location again.

Switching between 'Always' and 'when in use' should not ever result in stopping your location tracking. Likely it happened because I went to Never and stayed for more than 10 seconds, then switched to Always and then 'when in use' and I did all that—without opening the app and thought it was because I changed from Always to 'when in use'. So this was somewhat a false alarm.

mfaani
  • 33,269
  • 19
  • 164
  • 293