Location tracking by Flutter app in terminated mode

Viewed 257

We are developing Flutter application that should track geography location and post it to backend server. Actually We're using our custom tracking plugin with native code with CoreLocation This tracking should occur in all modes (foreground and background) and works fine It sends received location to Flutter channel and Dart code receives it and posts to backend (this part is pure dart code).

But additional requirement is: tracking should occur when it's terminated.

For Signing&Capabilities we set Location updates, background fetch and notification.

Info.plists contains following modes

    <key>UIBackgroundModes</key>
    <array>
        <string>fetch</string>
        <string>location</string>
        <string>remote-notification</string>
    </array>

We also added text for keys

NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription

We are initialise CLLocationManager and successfully requesting manager.requestAlwaysAuthorization() and do locationManager.startMonitoringSignificantLocationChanges()

Similar code on "pure" iOS application without Flutter works fine. For example on simulator I see it writing locations into file even when application is terminated.

For Flutter application it works fine in background but it stops when I terminate the application. My understanding -- it still receives locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) receives locations But it can not send it to Flutter channel

So our question is:

  1. Is it possible at all? Does Flutter supports it?
  2. If yes -- what additional steps we need to do to re-initialise Flutter engine when receives new location in such terminated mode.

Thanks

0 Answers
Related