Skip to content

Commit cdd04e6

Browse files
committed
wip
1 parent 3c77a9c commit cdd04e6

File tree

15 files changed

+1243
-46
lines changed

15 files changed

+1243
-46
lines changed

Example/ViewController.swift

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ class ViewController: UIViewController {
282282
navigationViewController.floatingButtonsPosition = .topTrailing
283283

284284
presentAndRemoveNavigationMapView(navigationViewController, completion: beginCarPlayNavigation)
285+
286+
DispatchQueue.main.asyncAfter(deadline: .now() + 15.0) {
287+
self.goBack()
288+
}
285289
}
286290

287291
func startCustomNavigation() {
@@ -577,6 +581,9 @@ extension ViewController: NavigationViewControllerDelegate {
577581
let carPlayNavigationViewController = delegate.carPlayManager.carPlayNavigationViewController {
578582
return carPlayNavigationViewController.navigationService(navigationViewController.navigationService, didArriveAt: waypoint)
579583
}
584+
// DispatchQueue.main.async {
585+
// self.activeNavigationViewController?.navigationService.start()
586+
// }
580587
return true
581588
}
582589

@@ -586,3 +593,53 @@ extension ViewController: NavigationViewControllerDelegate {
586593
clearNavigationMapView()
587594
}
588595
}
596+
597+
extension ViewController {
598+
func continueRouting() {
599+
let nvc = self.activeNavigationViewController!
600+
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
601+
nvc.navigationService.router.reroute(from: nvc.navigationService.locationManager.location!, along: nvc.navigationService.routeProgress)
602+
}
603+
}
604+
func goBack() {
605+
guard let coordinate = activeNavigationViewController!.navigationMapView!.mapView.location.latestLocation?.coordinate else {
606+
print("User location is not valid. Make sure to enable Location Services.")
607+
return
608+
}
609+
610+
let location = CLLocation(latitude: coordinate.latitude,
611+
longitude: coordinate.longitude)
612+
let userWaypoint = Waypoint(location: location)
613+
waypoints.remove(at: 1)
614+
waypoints.insert(userWaypoint, at: 0)
615+
616+
let returnRouteOptions = NavigationRouteOptions(waypoints: waypoints)
617+
618+
// guard let response = response, let route = response.routes?.first, case let .route(routeOptions) = response.options else { return }
619+
//
620+
// let service = navigationService(route: route, routeIndex: 0, options: routeOptions)
621+
// let navigationViewController = self.navigationViewController(navigationService: service)
622+
//
623+
Directions.shared.calculate(returnRouteOptions) { (session, result) in
624+
switch result {
625+
case .failure(let error):
626+
print("Error getting directions: \(error.localizedDescription)")
627+
case .success(let response):
628+
guard let route = response.routes?.first else {
629+
return
630+
}
631+
632+
// let rc = (self.activeNavigationViewController?.navigationService.router as! RouteController)
633+
// rc.routeProgress = RouteProgress(route: route, routeIndex: 0, options: returnRouteOptions)
634+
// self.activeNavigationViewController?.indexedRoute = (route, 0)
635+
let nvc = self.activeNavigationViewController!
636+
nvc.navigationService.router.updateRoute(with: (route, 0), routeOptions: returnRouteOptions)
637+
nvc.navigationService.start()
638+
// self.currentMapRoute = route
639+
// // If we've already got a nav service then update it, otherwise create a new one
640+
// self.currentNavigationViewController?.indexedRoute = IndexedRoute(route, 0)
641+
642+
}
643+
}
644+
}
645+
}

MapboxNavigation-SPM.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MapboxNavigation.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
2B91C9B12416357700E532A5 /* MapboxSpeechSynthesizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B91C9B02416357700E532A5 /* MapboxSpeechSynthesizer.swift */; };
4646
2B955B1C25EFDDCB00BBFEC6 /* Directions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B955B1B25EFDDCB00BBFEC6 /* Directions.swift */; };
4747
2BBED92F265E2C7D00F90032 /* NativeHandlersFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BBED92E265E2C7D00F90032 /* NativeHandlersFactory.swift */; };
48+
2BBED93B267A3AB900F90032 /* BillingHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BBED93A267A3AB900F90032 /* BillingHandler.swift */; };
4849
2BBEEDA52508DB1700C8DA4A /* RouteLegProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BBEEDA42508DB1700C8DA4A /* RouteLegProgress.swift */; };
4950
2BBEEDA72508E1E300C8DA4A /* RouteStepProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BBEEDA62508E1E300C8DA4A /* RouteStepProgress.swift */; };
5051
2BDD653D2614BCA1005B8B55 /* WayNameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BDD653C2614BCA1005B8B55 /* WayNameView.swift */; };
@@ -342,6 +343,7 @@
342343
DAFA92071F01735000A7FB09 /* DistanceFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 351BEC0B1E5BCC72006FE110 /* DistanceFormatter.swift */; };
343344
E23D8B6B269D7EE90094CEFA /* TilesetDescriptorFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E23D8B6A269D7EE90094CEFA /* TilesetDescriptorFactoryTests.swift */; };
344345
E26AB4FD269F7BCA00FD756B /* TestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = E26AB4FC269F7BCA00FD756B /* TestCase.swift */; };
346+
E2814D982693412E000AD987 /* BillingHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2814D972693412E000AD987 /* BillingHandlerTests.swift */; };
345347
E2842798265B907C003F86E4 /* UnimplementedLoggingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2842797265B907C003F86E4 /* UnimplementedLoggingTests.swift */; };
346348
E2922DEB26A55B0E0094D3BE /* NSLock++.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2922DEA26A55B0E0094D3BE /* NSLock++.swift */; };
347349
E2C1CDA0265E22AA00E158E0 /* MapboxDirections.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2C1CD9F265E22AA00E158E0 /* MapboxDirections.xcframework */; };
@@ -503,6 +505,7 @@
503505
2B91C9B02416357700E532A5 /* MapboxSpeechSynthesizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapboxSpeechSynthesizer.swift; sourceTree = "<group>"; };
504506
2B955B1B25EFDDCB00BBFEC6 /* Directions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Directions.swift; sourceTree = "<group>"; };
505507
2BBED92E265E2C7D00F90032 /* NativeHandlersFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativeHandlersFactory.swift; sourceTree = "<group>"; };
508+
2BBED93A267A3AB900F90032 /* BillingHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BillingHandler.swift; sourceTree = "<group>"; };
506509
2BBEEDA42508DB1700C8DA4A /* RouteLegProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouteLegProgress.swift; sourceTree = "<group>"; };
507510
2BBEEDA62508E1E300C8DA4A /* RouteStepProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouteStepProgress.swift; sourceTree = "<group>"; };
508511
2BDD653C2614BCA1005B8B55 /* WayNameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WayNameView.swift; sourceTree = "<group>"; };
@@ -906,6 +909,7 @@
906909
E26AB4FC269F7BCA00FD756B /* TestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestCase.swift; sourceTree = "<group>"; };
907910
E27A21F22654FB6800AA935F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
908911
E27A21FD265672D500AA935F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
912+
E2814D972693412E000AD987 /* BillingHandlerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BillingHandlerTests.swift; sourceTree = "<group>"; };
909913
E2842797265B907C003F86E4 /* UnimplementedLoggingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnimplementedLoggingTests.swift; sourceTree = "<group>"; };
910914
E2922DEA26A55B0E0094D3BE /* NSLock++.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSLock++.swift"; sourceTree = "<group>"; };
911915
E2C1CD9F265E22AA00E158E0 /* MapboxDirections.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = MapboxDirections.xcframework; path = Carthage/Build/MapboxDirections.xcframework; sourceTree = "<group>"; };
@@ -1581,6 +1585,7 @@
15811585
C56173591F182103005954F6 /* Extensions */,
15821586
C53C196A1F38E9C1008DB406 /* Resources */,
15831587
DABA591425E58D5600D0C1DB /* Accounts.swift */,
1588+
2BBED93A267A3AB900F90032 /* BillingHandler.swift */,
15841589
C58D6BAC1DDCF2AE00387F53 /* CoreConstants.swift */,
15851590
351BEC0B1E5BCC72006FE110 /* DistanceFormatter.swift */,
15861591
8DCE104F210FC5880048B0FB /* EndOfRouteFeedback.swift */,
@@ -1645,6 +1650,7 @@
16451650
5A43FC8A24B488DC00BF7943 /* PassiveLocationManagerTests.swift */,
16461651
E2842797265B907C003F86E4 /* UnimplementedLoggingTests.swift */,
16471652
E23D8B6A269D7EE90094CEFA /* TilesetDescriptorFactoryTests.swift */,
1653+
E2814D972693412E000AD987 /* BillingHandlerTests.swift */,
16481654
);
16491655
name = MapboxCoreNavigationTests;
16501656
path = Tests/MapboxCoreNavigationTests;
@@ -2468,6 +2474,7 @@
24682474
DAF27252264E02D800C0AC37 /* RoadObject.swift in Sources */,
24692475
5A39B9282498F9890026DFD1 /* PassiveLocationManager.swift in Sources */,
24702476
C5C94C1D1DDCD2370097296A /* RouteProgress.swift in Sources */,
2477+
2BBED93B267A3AB900F90032 /* BillingHandler.swift in Sources */,
24712478
2BE701352535948100F46E4E /* RestStop.swift in Sources */,
24722479
8D4CF9C621349FFB009C3FEE /* NavigationServiceDelegate.swift in Sources */,
24732480
C5CFE4881EF2FD4C006F48E8 /* MMEEventsManager.swift in Sources */,
@@ -2503,6 +2510,7 @@
25032510
C52AC1261DF0E48600396B9F /* RouteProgressTests.swift in Sources */,
25042511
5A43FC8B24B488DC00BF7943 /* PassiveLocationManagerTests.swift in Sources */,
25052512
359574AA1F28CCBB00838209 /* LocationTests.swift in Sources */,
2513+
E2814D982693412E000AD987 /* BillingHandlerTests.swift in Sources */,
25062514
C582BA2C2073E77E00647DAA /* StringTests.swift in Sources */,
25072515
B426FEF425FFD5DC001884C8 /* RouteControllerTests.swift in Sources */,
25082516
352762A4225B751A0015B632 /* OptionsTests.swift in Sources */,

Package.resolved

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let package = Package(
2626
.package(name: "MapboxDirections", url: "https://github.com/mapbox/mapbox-directions-swift.git", .exact("2.0.0-beta.6")),
2727
.package(name: "MapboxMobileEvents", url: "https://github.com/mapbox/mapbox-events-ios.git", from: "1.0.0"),
2828
.package(name: "MapboxNavigationNative", url: "https://github.com/mapbox/mapbox-navigation-native-ios.git", from: "56.0.0"),
29-
.package(name: "MapboxMaps", url: "https://github.com/mapbox/mapbox-maps-ios.git", .exact("10.0.0-rc.3")),
29+
.package(name: "MapboxMaps", url: "https://github.com/mapbox/mapbox-maps-ios.git", .branch("main")),
3030
.package(name: "Solar", url: "https://github.com/ceeK/Solar.git", from: "3.0.0"),
3131
.package(name: "MapboxSpeech", url: "https://github.com/mapbox/mapbox-speech-swift.git", from: "2.0.0-alpha.1"),
3232
.package(name: "Quick", url: "https://github.com/Quick/Quick.git", from: "3.1.2"),

Sources/MapboxCoreNavigation/Accounts.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ enum NavigationBillingMethod: String {
1111
@objc(MBXAccounts)
1212
public class Accounts: NSObject {
1313
@objc public static var serviceSkuToken: String? {
14-
var billingMethodValue = Bundle.main.object(forInfoDictionaryKey: "MBXNavigationBillingMethod") as? String
15-
if billingMethodValue == "" {
16-
billingMethodValue = nil
17-
}
18-
19-
switch NavigationBillingMethod(rawValue: billingMethodValue ?? NavigationBillingMethod.user.rawValue) {
20-
case .user:
21-
return TokenGenerator.getSKUToken(for: .navigationMAUS)
22-
case .request:
23-
return nil
24-
case .none:
25-
preconditionFailure("Unrecognized billing method \(String(describing: billingMethodValue)). Valid billing methods are: \(NavigationBillingMethod.allValues.map { $0.rawValue }).")
26-
}
14+
return BillingHandler.shared.serviceSkuToken
2715
}
2816
}

0 commit comments

Comments
 (0)