You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This SDK is designed so that the application can specify a Mapbox access token programmatically at runtime as an alternative to specifying it in the Info.plist file. However, by default, if the application specifies the access token by setting MGLAccountManager.accessToken and passing an access token into Directions(accessToken:), instructions are spoken by VoiceOver instead of by Amazon Polly via the Mapbox Voice API.
Diagnosis
By default, NavigationViewController(for:styles:navigationService:voiceController:) creates a MapboxVoiceController with no arguments:
But in a Release build, the library would request audio without an access token, and the Voice API would return an error, causing MapboxVoiceController to fall back to VoiceOver via RouteVoiceController.
A fix would look similar to the workaround: by default, NavigationViewController would create a MapboxVoiceController that uses the same access token and API endpoint as the NavigationService:
Note that MapboxNavigationService(route:directions:locationSource:eventsManagerType:simulating:routerType:) also defaults to Directions.shared, which reads the access token from the Info.plist file:
So even with this fix, the application would still be required to pass a NavigationService into NavigationViewController(for:styles:navigationService:voiceController:) instead of relying on the default NavigationService. Specifying an access token at runtime requires a lot of fiddling, which is why the Info.plist key is supported as a global configuration option.
/cc @mapbox/navigation-ios
The text was updated successfully, but these errors were encountered:
This SDK is designed so that the application can specify a Mapbox access token programmatically at runtime as an alternative to specifying it in the Info.plist file. However, by default, if the application specifies the access token by setting
MGLAccountManager.accessToken
and passing an access token intoDirections(accessToken:)
, instructions are spoken by VoiceOver instead of by Amazon Polly via the Mapbox Voice API.Diagnosis
By default,
NavigationViewController(for:styles:navigationService:voiceController:)
creates a MapboxVoiceController with no arguments:mapbox-navigation-ios/MapboxNavigation/NavigationViewController.swift
Line 369 in 9c49ade
By default,
MapboxVoiceController(speechClient:dataCache:audioPlayerType:)
creates a SpeechSynthesizer with no access token:mapbox-navigation-ios/MapboxNavigation/MapboxVoiceController.swift
Line 38 in 9c49ade
By default, SpeechSynthesizer reads the access token out of the Info.plist file:
https://github.com/mapbox/mapbox-speech-swift/blob/b6b7a8f430efdd9a2945fb2a91347dfc501e7428/MapboxSpeech/MapboxSpeech.swift#L9
With a Debug build of MapboxSpeech, this assertion would fail:
https://github.com/mapbox/mapbox-speech-swift/blob/b6b7a8f430efdd9a2945fb2a91347dfc501e7428/MapboxSpeech/MapboxSpeech.swift#L89-L90
But in a Release build, the library would request audio without an access token, and the Voice API would return an error, causing MapboxVoiceController to fall back to VoiceOver via RouteVoiceController.
Workaround
Proposed fix
A fix would look similar to the workaround: by default, NavigationViewController would create a MapboxVoiceController that uses the same access token and API endpoint as the NavigationService:
For this to work,
RouteOptions.accessToken
needs to be made public: mapbox/mapbox-directions-swift#308.Note that
MapboxNavigationService(route:directions:locationSource:eventsManagerType:simulating:routerType:)
also defaults toDirections.shared
, which reads the access token from the Info.plist file:mapbox-navigation-ios/MapboxCoreNavigation/NavigationService.swift
Line 246 in 9c49ade
So even with this fix, the application would still be required to pass a NavigationService into
NavigationViewController(for:styles:navigationService:voiceController:)
instead of relying on the default NavigationService. Specifying an access token at runtime requires a lot of fiddling, which is why the Info.plist key is supported as a global configuration option./cc @mapbox/navigation-ios
The text was updated successfully, but these errors were encountered: