Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: waypoint didArrive: is never called if audio instructions are not enabled. #72

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#endif
```
* Custom location snapping in the `RouteController` via the delegate
* Fix: If the directions API endpoint doesn't include audio instructions, `didArrive:` would never be called.
* Merged in <https://github.com/maplibre/maplibre-navigation-ios/pull/72>

## 3.0.0 (Jun 15, 2024)
* The `speak` method in `RouteVoiceController` can be used without a given `RouteProgress` or the `RouteProgress` can explicitly ignored so that it will not be added to the voice instruction.
Expand Down
7 changes: 5 additions & 2 deletions MapboxCoreNavigation/RouteController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,12 @@

func updateRouteLegProgress(for location: CLLocation) {
let currentDestination = self.routeProgress.currentLeg.destination
guard let remainingVoiceInstructions = routeProgress.currentLegProgress.currentStepProgress.remainingSpokenInstructions else { return }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there were no voice instructions to begin with, we can never "arrive".

var hasRemainingVoiceInstructions = false
if let remainingVoiceInstructions = routeProgress.currentLegProgress.currentStepProgress.remainingSpokenInstructions, remainingVoiceInstructions.count > 0 {
hasRemainingVoiceInstructions = true
}

if self.routeProgress.currentLegProgress.remainingSteps.count <= 1, remainingVoiceInstructions.count == 0, currentDestination != self.previousArrivalWaypoint {
if self.routeProgress.currentLegProgress.remainingSteps.count <= 1, !hasRemainingVoiceInstructions, currentDestination != self.previousArrivalWaypoint {
self.previousArrivalWaypoint = currentDestination

self.routeProgress.currentLegProgress.userHasArrivedAtWaypoint = true
Expand Down Expand Up @@ -669,7 +672,7 @@
if let _ = error { return }
guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 else { return }

guard let data, let currentVersion = String(data: data, encoding: .utf8)?.trimmingCharacters(in: .newlines) else { return }

Check warning on line 675 in MapboxCoreNavigation/RouteController.swift

View workflow job for this annotation

GitHub Actions / Code Style

Prefer using UTF-8 encoded strings when converting between `String` and `Data` (non_optional_string_data_conversion)

if latestVersion != currentVersion {
let updateString = NSLocalizedString("UPDATE_AVAILABLE", bundle: .mapboxCoreNavigation, value: "Mapbox Navigation SDK for iOS version %@ is now available.", comment: "Inform developer an update is available")
Expand Down
Loading