Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ extension AugmentRealityToNavigateRouteView {
}

statusText = "Navigation will start."

// The category is set so that the navigation instructions are spoken even when silent mode is turned on.
let session = AVAudioSession.sharedInstance()
try session.setCategory(.playback, mode: .voicePrompt)
try session.setActive(true)

await startTracking()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

import ArcGIS
import AVFAudio
import SwiftUI

struct NavigateRouteWithReroutingView: View {
Expand Down Expand Up @@ -99,6 +100,15 @@ struct NavigateRouteWithReroutingView: View {
.task(id: model.isNavigating) {
guard model.isNavigating, let routeTracker = model.routeTracker else { return }

do {
// The category is set so that the navigation instructions are spoken even when silent mode is turned on.
let session = AVAudioSession.sharedInstance()
try session.setCategory(.playback, mode: .voicePrompt)
try session.setActive(true)
} catch {
self.error = error
}

await withTaskGroup(of: Void.self) { group in
group.addTask { @MainActor @Sendable in
// Handle new tracking statuses from the route tracker.
Expand Down
8 changes: 8 additions & 0 deletions Shared/Samples/Navigate route/NavigateRouteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ private extension NavigateRouteView {

/// Starts monitoring multiple asynchronous streams of information.
private func startTracking() async {
do {
// The category is set so that the navigation instructions are spoken even when silent mode is turned on.
let session = AVAudioSession.sharedInstance()
try session.setCategory(.playback, mode: .voicePrompt)
try session.setActive(true)
} catch {
self.error = error
}
await withTaskGroup(of: Void.self) { group in
group.addTask { await self.trackAutoPanMode() }
group.addTask { await self.trackStatus() }
Expand Down
Loading