Do I need to maintain CLServiceSession when app relaunches from terminated state due to CLMonitor events?

I'm currently testing the CLMonitor API and have a question about CLServiceSession management.

When my app is relaunched from a terminated state in the background due to CLMonitor events, do I still need to create and maintain a CLServiceSession instance?

I'm wondering if CLServiceSession is necessary even when I don't need to continuously receive GPS updates through liveUpdates. Since CLMonitor can trigger app launches for region monitoring events without requiring constant location updates, I'm unclear about whether the CLServiceSession is still required in this scenario.

Any clarification on the proper implementation would be greatly appreciated.

Thanks!

Answered by Engineer in 856544022

An explicit CLServiceSession is optional. If you do not specify NSLocationRequireExplicitServiceSession in your Info.plist, Core Location will create an implicit service session with When in Use authorization.

Monitoring location changes with Core Location demonstrates using CLMonitor without an explicit CLServiceSession.

But if you want more control, over your authorization, and make use of the diagnostics provided, you would want an explicit session.

If you are using an explicit session, you will want to recreate the session asap upon launch in the background, otherwise your app will be assumed to no longer have interest in location updates, and you will need to start over when the app is in the foreground.

Accepted Answer

An explicit CLServiceSession is optional. If you do not specify NSLocationRequireExplicitServiceSession in your Info.plist, Core Location will create an implicit service session with When in Use authorization.

Monitoring location changes with Core Location demonstrates using CLMonitor without an explicit CLServiceSession.

But if you want more control, over your authorization, and make use of the diagnostics provided, you would want an explicit session.

If you are using an explicit session, you will want to recreate the session asap upon launch in the background, otherwise your app will be assumed to no longer have interest in location updates, and you will need to start over when the app is in the foreground.

Do I need to maintain CLServiceSession when app relaunches from terminated state due to CLMonitor events?
 
 
Q