1

In my app i start to listen Significant Location Changes like this :

AllowsBackgroundLocationUpdates := true;
startMonitoringSignificantLocationChanges;

in the info.plist i have also :

<key>UIBackgroundModes</key>
<array>
    <string>location</string>
</array>

Then i decide to reboot the iphone. After i move around all the city i notice that DidUpdateLocations is never called anymore :( what did i miss ?

I m also in Delphi if it's can matter ...

zeus
  • 12,173
  • 9
  • 63
  • 184
  • Does you application starts back after reboot of iPhone? Or does is start when it is used for the first time (launched by you)? – SilverWarior Jul 20 '17 at 16:06
  • this is the problem, the app don't seam to start after the reboot of the iphone :( – zeus Jul 20 '17 at 16:23

1 Answers1

1

As per this link:

recieving location updates after app is terminated

There are factors that will determine whether your code is executed, namely, your app needs to:

  • Set location services active during the didFinishLaunchingWithOptions call, and it needs to be for changes of type: lctLarge (LocationChange property on TLocationSensor), if the app was launched due to a location change (UIApplicationLaunchOptionsLocationKey is present in launchOptions)

  • Call setAllowsBackgroundUpdates(True) (for iOS 9 and later) so that it actually receives location updates in the background, in addition to having location included in UIBackgroundModes

  • Call requestAlwaysAuthorization, so that your app can be launched into the background.

Implementing the first requirement could be done in a couple of ways, either by "patching" FMX.Platform.iOS so that launching due to a location change sends a message that your code can intercept, or by intercepting the FinishedLaunching message (without the need for a patch), except that in the latter case, you might not be able to determine whether or not the app was launched due to a location change. This may not matter though, as you could also intercept the BecameActive event, where you can set LocationChange to lctSmall, if required.

In any scenario, you will not see your app appear if it is launched (i.e. was not running to begin with) due to a location change, as iOS keeps the app "invisible". You can however verify that the code works by logging the location updates with timestamps so you know when the changes occurred.

Dave Nottage
  • 3,411
  • 1
  • 20
  • 57