のメソッドで返されるのspeed
プロパティは、CarPlay が接続されたときに一部の車種で高くなるようです。CLLocation
CLLocationManager
didUpdateLocations
デモ プロジェクトは CarPlay サポートなしで問題を再現できるため、これはアプリでの CarPlay ナビゲーション サポートとは関係がないようです。
これが発生することが確認されている特定の車種は次のとおりです。
- ボルボ XC90
- Sync 3 を搭載した Ford トランジット
- Rlink2 および最新のファームウェアを搭載したルノー メガーヌ IV モデル 2018
- オペル アストラ駅 (2018)
- フォード フォーカス 2017
- Opel Astra (モデル K、2017) — GPS 速度の半分を取得
違いの例:
- 車の速度計: 120km/h
- からの GPS 速度
didUpdateLocations
: 115km/h didUpdateLocations
これらの車種の 1 つに接続された CarPlayからの GPS 速度: 130km/h
ここで、問題を再現するデモ プロジェクト (NL ロケールを使用) を見つけることができます: https://github.com/flitsmeister/carplay-speed-problem
関連部分:
override private init() {
super.init()
// These settings mimick the settings we have in our production app
locationManager.requestAlwaysAuthorization()
locationManager.delegate = self
locationManager.allowsBackgroundLocationUpdates = true
locationManager.activityType = .automotiveNavigation
locationManager.pausesLocationUpdatesAutomatically = false
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = kCLDistanceFilterNone
}
func startLocating() {
locationManager.startUpdatingLocation()
}
func stopLocating() {
locationManager.stopUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard lastLocation = locations.first else {
return
}
print(lastLocation.speed) // This property is higher when connected to CarPlay
}