What is new in CoreLocation

Generated on 8/4/2024

1 search

At WWDC 2024, Apple introduced several new features and improvements for CoreLocation, particularly focusing on location authorization. Here are the key updates:

  1. CL Service Session:

    • A new declarative way to manage location authorization goals for different features of your app.
    • Allows you to specify what kind of location access each feature needs while it is running.
    • Helps in reducing the complexity of authorization code in Swift.
  2. Implicit Service Sessions:

    • CoreLocation can now treat the act of iterating live updates or monitor events as implicitly holding a CL service session.
    • This means you may be able to update your app to handle CoreLocation authorization with service sessions just by deleting code.
    • If you don't want API use to implicitly motivate authorization requests, you can disable this behavior by setting the NSLocationRequireExplicitServiceSession key in your app's Info.plist.
  3. Diagnostic Properties:

    • New system of diagnostic properties to give your app a complete contextual understanding of its current authorization and the function of any other CoreLocation API objects.
    • These properties help in understanding why updates or events might not be yielded, reducing the need for timeouts and guesswork.
  4. Authorization Goals:

    • Moving from a procedural model to a declarative one for interacting with location authorization.
    • Simplifies the process of requesting location authorization and managing different states like "not determined," "when in use," and "denied."
  5. Session Lifecycle:

    • CL service sessions are aligned with user-facing features and interact with the app's lifecycle.
    • Features can be short-lived (e.g., geotagging a photo) or longer (e.g., browsing a MapKit view), and sessions can overlap as needed.

For more detailed information, you can watch the session "What’s new in location authorization" from WWDC 2024.