Widget links maps:// directly so CarPlay can route to Apple Maps
- The widget now uses the native maps://?daddr= scheme for taps in both sizes. In CarPlay there is no containing app to relay through, but since Apple Maps IS a CarPlay app, the system may route the tap straight to Maps on the car display (WWDC25: widgets can launch apps in CarPlay). - iOS keeps working via onOpenURL: the app now forwards maps:// URLs (if the Home Screen delivers them to the app), plus legacy fuelboard:// and http://maps.apple.com links from older cached timelines. - No public API exists for a widget to detect CarPlay context, so the single maps:// link serves both; the app-side forward is the iOS safety net. 35 tests pass.
This commit is contained in:
@@ -159,13 +159,16 @@ struct FuelStation: Identifiable, Codable, Equatable {
|
||||
URL(string: "maps://?daddr=\(lat),\(lng)&t=d")
|
||||
}
|
||||
|
||||
/// Widget tap URL. WidgetKit widgets can ONLY open their containing app:
|
||||
/// the system hands this URL to FuelBoard via `onOpenURL`, which then
|
||||
/// forwards to Apple Maps. So the widget link uses our own registered
|
||||
/// `fuelboard://` scheme rather than `maps://` (which would arrive in the
|
||||
/// app and be silently dropped).
|
||||
/// Widget tap URL — the native Maps scheme (`maps://`). From the iOS Home
|
||||
/// Screen the system may either (a) open Maps directly, or (b) deliver the
|
||||
/// URL to the containing app, where FuelBoardApp.onOpenURL forwards it to
|
||||
/// Maps. In CarPlay there is no containing app, but because `maps://`
|
||||
/// targets Apple Maps — an app that IS in CarPlay — the system may route
|
||||
/// the tap straight to the car display, bypassing the app entirely. This
|
||||
/// is the only scheme with a chance of working in CarPlay; the old
|
||||
/// `fuelboard://` relay is kept as a handled fallback in onOpenURL.
|
||||
var widgetDirectionsURL: URL? {
|
||||
URL(string: "fuelboard://directions?lat=\(lat)&lng=\(lng)")
|
||||
URL(string: "maps://?daddr=\(lat),\(lng)&t=d")
|
||||
}
|
||||
|
||||
/// Name of the bundled brand logo asset, or nil if unknown.
|
||||
|
||||
Reference in New Issue
Block a user