Skip to content

[Feature request]: onTurnByTurn listener in background #407

Description

@lemsdentsu

Is there an existing issue for this?

  • I have searched the existing issues

Use case

First, I'd like to thank all the contributors for your work on this library. Much appreciated.

In my application I'd like to use a custom voice to enhance the navigation. To do this I set the AudioGuidanceType to silent:

navigationController.setAudioGuidanceType(AudioGuidance.SILENT);

After starting the guidance, I use the onTurnByTurn callback to provide the user with directions when necessary.

  const onTurnByTurn = useCallback((turnByTurnEvent) => {
    // provide user with next direction based on distance from currentStep
  }, []);
  
  const navigationCallbacks = useMemo(
    () => ({
      onTurnByTurn,
    }),
    [onTurnByTurn],
  );

  useEffect(() => {
    addListeners(navigationCallbacks);

    return () => {
      removeListeners(navigationCallbacks);
      }
    };
  }, [navigationCallbacks, addListeners, removeListeners]);

When the app is active it all works as expected. The problem is that the onTurnByTurn callback is not triggered when the app is in the background. I'd like to still provide the user with the directions when the application is in the background.

The native audio guidance (the one i set to silent) does provide directions when the application is in the background.

I was thinking a workaround might be to get the next navigation step when onRemainingTimeOrDistanceChanged is called, since this function does get called when the app is in the background. But I found no way to fetch the next navigation step on demand.

Proposal

Either to execute the onTurnByTurn callback when the application is in the background as well as in the foreground. Or provide a way to fetch the data provided by TurnByTurnEvent on demand.

Metadata

Metadata

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions