Skip to content

Commit

Permalink
Single instance of MapboxNavigationProvider to prevent crashes on ios
Browse files Browse the repository at this point in the history
  • Loading branch information
YoussefHenna committed Aug 13, 2024
1 parent 4be2b59 commit 07ac0bb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ios/ExpoMapboxNavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ExpoMapboxNavigationView: ExpoView {


class ExpoMapboxNavigationViewController: UIViewController {
var navigationProvider: MapboxNavigationProvider? = nil
static let navigationProvider: MapboxNavigationProvider = MapboxNavigationProvider(coreConfig: .init(locationSource: .live))
var mapboxNavigation: MapboxNavigation? = nil
var routingProvider: RoutingProvider? = nil
var navigation: NavigationController? = nil
Expand Down Expand Up @@ -65,8 +65,7 @@ class ExpoMapboxNavigationViewController: UIViewController {

init() {
super.init(nibName: nil, bundle: nil)
navigationProvider = MapboxNavigationProvider(coreConfig: .init(locationSource: .live))
mapboxNavigation = navigationProvider!.mapboxNavigation
mapboxNavigation = ExpoMapboxNavigationViewController.navigationProvider.mapboxNavigation
routingProvider = mapboxNavigation!.routingProvider()
navigation = mapboxNavigation!.navigation()
tripSession = mapboxNavigation!.tripSession()
Expand Down Expand Up @@ -233,8 +232,8 @@ class ExpoMapboxNavigationViewController: UIViewController {

let navigationOptions = NavigationOptions(
mapboxNavigation: self.mapboxNavigation!,
voiceController: self.navigationProvider!.routeVoiceController,
eventsManager: self.navigationProvider!.eventsManager(),
voiceController: ExpoMapboxNavigationViewController.navigationProvider.routeVoiceController,
eventsManager: ExpoMapboxNavigationViewController.navigationProvider.eventsManager(),
topBanner: topBanner,
bottomBanner: bottomBanner
)
Expand Down

0 comments on commit 07ac0bb

Please sign in to comment.