Post

Replies

Boosts

Views

Activity

Reply to Lifecycle and Usage of CLServiceSession after the app is terminated
Hi, Thanks for your help! I was able to run the app without any issue but after upgrading Xcode to v26.x.x, I am having similar issue again. I’m encountering an issue with background location tracking stopping after the app remains in the background/killed mode for around 1–2 days. After some time in the background, the location events stop arriving entirely. While diagnosing the issue, I noticed logs/messages related to “service session required”. I would like clarification regarding CLServiceSession lifecycle management. Currently, I create the session locally inside a function like this: let session = CLServiceSession( authorization: .always, fullAccuracyPurposeKey: "Trip" ) I’m wondering whether the session being scoped locally could cause the service session to be deallocated or invalidated, eventually stopping background location delivery. Would it be more appropriate to maintain a strong reference at the class level, for example: private var serviceSession: CLServiceSession? and then initialize it as: serviceSession = CLServiceSession( authorization: .always, fullAccuracyPurposeKey: "Trip" ) Could the lack of a persistent reference to CLServiceSession affect: continuation of background location updates, service session validity, or app relaunch behavior after extended background execution? Could this behavior be related to ARC deallocating a locally scoped CLServiceSession instance after the function exits? Thanks.
May ’26
Reply to Lifecycle and Usage of CLServiceSession after the app is terminated
Hi, Thanks for your help! I was able to run the app without any issue but after upgrading Xcode to v26.x.x, I am having similar issue again. I’m encountering an issue with background location tracking stopping after the app remains in the background/killed mode for around 1–2 days. After some time in the background, the location events stop arriving entirely. While diagnosing the issue, I noticed logs/messages related to “service session required”. I would like clarification regarding CLServiceSession lifecycle management. Currently, I create the session locally inside a function like this: let session = CLServiceSession( authorization: .always, fullAccuracyPurposeKey: "Trip" ) I’m wondering whether the session being scoped locally could cause the service session to be deallocated or invalidated, eventually stopping background location delivery. Would it be more appropriate to maintain a strong reference at the class level, for example: private var serviceSession: CLServiceSession? and then initialize it as: serviceSession = CLServiceSession( authorization: .always, fullAccuracyPurposeKey: "Trip" ) Could the lack of a persistent reference to CLServiceSession affect: continuation of background location updates, service session validity, or app relaunch behavior after extended background execution? Could this behavior be related to ARC deallocating a locally scoped CLServiceSession instance after the function exits? Thanks.
Replies
Boosts
Views
Activity
May ’26