mapbox / mapbox/mapbox-navigation-ios

Ask the user whether to proactively reroute

Open
#2,740 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature jira-sync-complete platform parity workaround available
Dominant language
Swift
Stars
918
Forks
326
Avg merge
1h 16m
Merged PRs (30d)
3

Description

As long as Router.reroutesProactively is set to true, RouteController or LegacyRouteController automatically reroutes the user when it finds a faster route (subject to some heuristics around the time remaining to the destination). However, some applications may want to give the user the opportunity to accept or reject the new route, since the existing route is still valid.

NavigationViewController should optionally present a transient prompt upon receiving a faster route and reroute or stay on the current route based on the user’s choice. In CarPlay, the same UI can be implemented as a CPNavigationAlert with a duration. Both UIs would depend on new RouterDelegate.router(_:shouldProactivelyRerouteFrom:to:) and NavigationServiceDelegate.navigationService(_:shouldProactivelyRerouteFrom:to:) methods, which a custom UI could use to independently implement this prompt.

At the point where we set the new route, we currently only check a hard-coded heuristic, but this is a good opportunity to call RouterDelegate.router(_:shouldProactivelyRerouteFrom:to:) and perhaps also MapboxNavigationService.router(_:shouldRerouteFrom:):

https://github.com/mapbox/mapbox-navigation-ios/blob/0f00c9d3e36791b479e0a72e7937c37c1c089d16/MapboxCoreNavigation/Router.swift#L221-L223 https://github.com/mapbox/mapbox-navigation-ios/blob/0f00c9d3e36791b479e0a72e7937c37c1c089d16/MapboxCoreNavigation/RouteController.swift#L247-L248

We could implement these delegate methods as a first step before implementing any new UI.

There isn’t a perfect analogue on Android, but apparently an Android application can implement a callback similar to NavigationViewController.navigationService(_:didRerouteAlong:at:proactive:); the difference is that the Android application is responsible for setting the new route, whereas on iOS the SDK takes care of setting the new route automatically.

/cc @mapbox/navigation-ios

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Router.swift around lines 221–223 and RouteController.swift around lines 247–248, where proactive rerouting currently applies its heuristic. Review RouterDelegate and NavigationServiceDelegate, then implement the proposed reroute decision methods as the stated first step; done means callers can accept or reject the faster route before it is set.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.