Add leg notifications - #8
Conversation
Port MapLibre Android leg notifications support so iOS can warn about risks such as ferry crossings without parsing raw JSON. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Keep a Swift-only API while retaining NSSecureCoding for RouteLeg archiving. Co-authored-by: Cursor <cursoragent@cursor.com>
A type named Notification collided with Foundation.Notification and broke NotificationCenter observers in MapLibre Navigation. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
Adds first-class support for Directions API “notification” objects on RouteLeg, enabling clients to surface leg-level alerts/violations (for example ferry crossings and vehicle-dimension restriction violations) and to round-trip these models through JSON and NSSecureCoding.
Changes:
- Introduced
RouteNotification,RouteNotificationDetails, and related type/subtype/refresh/reason value types. - Added
RouteLeg.notifications, parsed from leg JSON and archived viaNSSecureCoding(defaulting to[]when absent). - Added unit tests covering parsing, JSON wire-name serialization, forward-compatibility of unknown values, and secure-coding round trips.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| MapboxDirections/MBRouteNotification.swift | New notification models (types/details/secure coding/JSON representation). |
| MapboxDirections/MBRouteLeg.swift | Parses and archives notifications on RouteLeg with an empty-array default. |
| MapboxDirectionsTests/NotificationTests.swift | New tests validating notification parsing/serialization/secure-coding behavior. |
| MapboxDirections.xcodeproj/project.pbxproj | Adds new source/test files to Xcode build phases/groups. |
| CHANGELOG.md | Documents the new route-leg notification support under “Unreleased”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
bugbot run |
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 437ccfe. Configure here.

Description of PR
In this PR we are adding notifications to route legs. These offer us the possibility to warn drivers of potential risks on their route. These notifications are implemented in accordance with the Mapbox spec outlined here.
This is the iOS counterpart of maplibre/maplibre-navigation-android#230.
Why
At Flitsmeister we are looking to implement ferry notifications in our routing module. At the moment the
RouteLegobject does not know how to parse said ferry notifications, so we could either parse the raw JSON ourselves and hack some way around it, or we could add it to theRouteLegobject as an expansion.Changes
Notification,NotificationDetails, and related type/subtype/refresh modelsRouteLeg.notifications(defaults to an empty array when absent)Test plan
swift test --filter NotificationTestsRouteLeg.notificationsMade with Cursor