Hi All,
I am currently working on an app that has some navigation functionality, and since my minimum iOS is 18 wanted to incorporate the new APIs that yield a AsyncStream of locations. I have watched both WWDC sessions, the one where the new API is introduced to retrieve the location points, and also the other video where the new authorization process for location is simplified as well.
I have an app currently working in its current state, but am noticing some weird quirks when using the CLBackgroundActivitySession to get the elevated background permission.
What I am doing here is to create this stream and the background object is below:
return AsyncThrowingStream { continuation in
let task = Task {
do {
for try await update in CLLocationUpdate.liveUpdates(updateType) {
if shouldStopUpdate {
continuation.finish()
break
}
continuation.yield(update)
}
} catch {
continuation.finish(throwing: error)
}
}
state = .started(locationTask: task, background: CLBackgroundActivitySession())
}
When I have an active navigation session going and am strongly holding this object and the user force quits the app (or I stop the target through Xcode) the navigation activity indicator in the status bar (or dynamic island) remains present. Even if I relaunch the app, start navigation again, and then call the invalidate method on the CLBackgroundActivitySession I then am seeing that navigation indicator even if I delete my app, and often need to do a full restart to get out of this state.
Is there a step I am missing, or do I not understand the way the new API works to run in the background?