It isn't significant location change or a location push, and it isn't something the extension calls.
The documentation is too brief there. All it means is that if you need continuous or frequent locations, your app should be producing them with its own live updates, instead of your server sending the extension one location push after another.
For "passing-off" liveUpdates(_:) to the main app from the LPSE, nothing gets handed over for you. You have to build it.
Or is your question about passing the location data obtained by the extension to the main app? If that is what you believe you will want to do after reading my answer here, I explain your options for implementing that in an article at 7strikes.dev
First, what is documented:
- The extension gets a push, finds a location, reports it, and its time is up. A device gets about 360 location pushes a day (Creating a location push service extension).
- An app receiving live updates in a
CLBackgroundActivitySession keeps receiving them in the background, and if it is terminated, Core Location launches it in the background again when there are updates. On that launch you call liveUpdates(_:) again and recreate your session objects (Discover streamlined location updates, WWDC23). - A
CLBackgroundActivitySession can only be started while the app is in the foreground. From the background you can only rejoin one you started earlier. CLServiceSession works the same way (Handling location updates in the background).
Put those together and the extension has no way to start continuous updates in your app. So:
- When the person turns on continuous sharing, with your app on screen, start live updates with a background activity session and a service session, and keep them running until they turn it off. Save the fact that sharing is on, and start all of it again at every launch while it is.
- Use the extension for the occasional request while continuous sharing is off.
- If the extension thinks that continuous sharing should start, all it can do is leave a note in your App Group container. The app acts on it the next time the person opens it, or it starts running due to a background function.
// When sharing is turned on, with the app on screen,
// and again at every launch while it's on.
service = CLServiceSession(authorization: .always)
background = CLBackgroundActivitySession()
updates = Task {
for try await update in CLLocationUpdate.liveUpdates() {
if let location = update.location { report(location) }
}
}
Significant location change can also bring a terminated app back, but your app has to start that too, so it doesn't change the answer.
If what you want to do is to get the locations in the extension and pass it on to the main app, the article at 7strikes.dev about app extensions and their containing apps goes through this, along with the other extension types. Along with some hints to help you determine if you actually need to do this at all.