how do i track location in the background?
Generated on 8/2/2024
1 search
To track location in the background, you can utilize CoreLocation's service sessions. Here are some key points from the session "What’s new in location authorization" at WWDC 2024:
-
Implicit and Explicit Sessions: CoreLocation uses both implicit and explicit sessions to manage location updates. Implicit sessions are created automatically when you start using location services, while explicit sessions are created manually by the developer to assert the app's continued interest in location updates.
-
Handling Background and Termination: CoreLocation can resume or relaunch your app into the background when new information is ready for delivery, provided the app's authorization allows it. This ensures that even if the app is terminated, it can still track activities like workouts. For more details, you can refer to the session What’s new in location authorization (11:47).
-
Authorization Goals: It's important to define your authorization goals clearly. For example, if your app needs full accuracy for certain features, you should hold a CL service session requiring full accuracy when those features are engaged. This proactive approach ensures that CoreLocation knows your app's needs and can act accordingly. For more information, see What’s new in location authorization (09:25).
-
Session Lifecycle: Align your CoreLocation sessions with user-facing features. This means creating and holding CL service session objects around these feature sessions. This approach helps manage the app's lifecycle events and ensures that location updates are handled appropriately even when the app is in the background. For more details, refer to What’s new in location authorization (09:25).
Relevant Sessions
By following these guidelines, you can effectively track location in the background while ensuring that your app remains compliant with user privacy and authorization settings.
What’s new in location authorization
Location authorization is turning 2.0. Learn about new recommendations and techniques to get the authorization you need, and a new system of diagnostics that can let you know when an authorization goal can’t be met.
What’s new in DockKit
Discover how intelligent tracking in DockKit allows for smoother transitions between subjects. We will cover what intelligent tracking is, how it uses an ML model to select and track subjects, and how you can use it in your app.