Drop deprecated MapKit and ActivityKit calls, and a dead capture
- RoadDistanceService builds route endpoints with MKMapItem(location:address:) instead of the MKPlacemark path deprecated in iOS 26. - LiveActivityManager updates through ActivityContent, replacing the ActivityKit update(using:) call deprecated in iOS 16.2. - The location-update hook no longer captures an unused state object; the closure body already runs on self, so behaviour is unchanged.
This commit is contained in:
@@ -161,7 +161,7 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func installLocationUpdateHook() {
|
private func installLocationUpdateHook() {
|
||||||
locationManager.onLocationUpdate = { [weak monitor] in
|
locationManager.onLocationUpdate = {
|
||||||
self.updateAlertMonitor()
|
self.updateAlertMonitor()
|
||||||
// The Live Activity follows the same wake-ups — this hook
|
// The Live Activity follows the same wake-ups — this hook
|
||||||
// fires on every fix incl. background significant-change
|
// fires on every fix incl. background significant-change
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ enum LiveActivityManager {
|
|||||||
currentStartDate = nil
|
currentStartDate = nil
|
||||||
start(attributes: attributes, state: state)
|
start(attributes: attributes, state: state)
|
||||||
} else {
|
} else {
|
||||||
Task { await current.update(using: state) }
|
Task { await current.update(ActivityContent(state: state, staleDate: nil)) }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
start(attributes: attributes, state: state)
|
start(attributes: attributes, state: state)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
// every row at once; the mode must also be ON for any pass to run at all.
|
// every row at once; the mode must also be ON for any pass to run at all.
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import CoreLocation
|
||||||
import MapKit
|
import MapKit
|
||||||
import UIKit
|
import UIKit
|
||||||
import WidgetKit
|
import WidgetKit
|
||||||
@@ -407,8 +408,14 @@ enum RoadDistanceService {
|
|||||||
/// Driving distance (metres) between two coordinates via Apple Maps routing.
|
/// Driving distance (metres) between two coordinates via Apple Maps routing.
|
||||||
private static func roadMeters(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) async -> Double? {
|
private static func roadMeters(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) async -> Double? {
|
||||||
let request = MKDirections.Request()
|
let request = MKDirections.Request()
|
||||||
request.source = MKMapItem(placemark: MKPlacemark(coordinate: from))
|
request.source = MKMapItem(
|
||||||
request.destination = MKMapItem(placemark: MKPlacemark(coordinate: to))
|
location: CLLocation(latitude: from.latitude, longitude: from.longitude),
|
||||||
|
address: nil
|
||||||
|
)
|
||||||
|
request.destination = MKMapItem(
|
||||||
|
location: CLLocation(latitude: to.latitude, longitude: to.longitude),
|
||||||
|
address: nil
|
||||||
|
)
|
||||||
request.transportType = .automobile
|
request.transportType = .automobile
|
||||||
request.requestsAlternateRoutes = false
|
request.requestsAlternateRoutes = false
|
||||||
do {
|
do {
|
||||||
|
|||||||
Reference in New Issue
Block a user