From e424b07759a3461945c1d5d89ae1e610189ddb94 Mon Sep 17 00:00:00 2001 From: Christopher Webb Date: Thu, 20 Nov 2025 15:09:14 -0800 Subject: [PATCH 01/12] update --- .../NavigateRouteWithReroutingView.Model.swift | 10 ++++++++++ Shared/Samples/Navigate route/NavigateRouteView.swift | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift index 12ba06628..c4b1d1f55 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift @@ -216,7 +216,17 @@ extension NavigateRouteWithReroutingView { /// - Parameter voiceGuidance: The `VoiceGuidance`. func speakVoiceGuidance(_ voiceGuidance: VoiceGuidance) { guard !voiceGuidance.text.isEmpty else { return } + do { + try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) + } catch let error as NSError { + print("Error: Could not set audio category: \(error), \(error.userInfo)") + } + do { + try AVAudioSession.sharedInstance().setActive(true) + } catch let error as NSError { + print("Error: Could not setActive to true: \(error), \(error.userInfo)") + } let utterance = AVSpeechUtterance(string: voiceGuidance.text) speechSynthesizer.stopSpeaking(at: .word) speechSynthesizer.speak(utterance) diff --git a/Shared/Samples/Navigate route/NavigateRouteView.swift b/Shared/Samples/Navigate route/NavigateRouteView.swift index 535546de1..95779e026 100644 --- a/Shared/Samples/Navigate route/NavigateRouteView.swift +++ b/Shared/Samples/Navigate route/NavigateRouteView.swift @@ -278,6 +278,17 @@ private extension NavigateRouteView { /// Monitors the asynchronous stream of voice guidances. private func trackVoiceGuidance() async { + do { + try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) + } catch let error as NSError { + print("Error: Could not set audio category: \(error), \(error.userInfo)") + } + + do { + try AVAudioSession.sharedInstance().setActive(true) + } catch let error as NSError { + print("Error: Could not setActive to true: \(error), \(error.userInfo)") + } for await voiceGuidance in routeTracker.voiceGuidances { speechSynthesizer.stopSpeaking(at: .word) speechSynthesizer.speak(AVSpeechUtterance(string: voiceGuidance.text)) From 02c50d544655dbd2c5ee3f651e3af56b9ff2d9e3 Mon Sep 17 00:00:00 2001 From: Christopher Webb Date: Thu, 20 Nov 2025 21:33:00 -0800 Subject: [PATCH 02/12] cleanup --- .../NavigateRouteWithReroutingView.Model.swift | 8 ++------ Shared/Samples/Navigate route/NavigateRouteView.swift | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift index c4b1d1f55..8dd8984f1 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift @@ -218,15 +218,11 @@ extension NavigateRouteWithReroutingView { guard !voiceGuidance.text.isEmpty else { return } do { try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) - } catch let error as NSError { - print("Error: Could not set audio category: \(error), \(error.userInfo)") - } - - do { try AVAudioSession.sharedInstance().setActive(true) } catch let error as NSError { - print("Error: Could not setActive to true: \(error), \(error.userInfo)") + print(error) } + let utterance = AVSpeechUtterance(string: voiceGuidance.text) speechSynthesizer.stopSpeaking(at: .word) speechSynthesizer.speak(utterance) diff --git a/Shared/Samples/Navigate route/NavigateRouteView.swift b/Shared/Samples/Navigate route/NavigateRouteView.swift index 95779e026..f93ddad92 100644 --- a/Shared/Samples/Navigate route/NavigateRouteView.swift +++ b/Shared/Samples/Navigate route/NavigateRouteView.swift @@ -280,15 +280,11 @@ private extension NavigateRouteView { private func trackVoiceGuidance() async { do { try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) - } catch let error as NSError { - print("Error: Could not set audio category: \(error), \(error.userInfo)") - } - - do { try AVAudioSession.sharedInstance().setActive(true) } catch let error as NSError { - print("Error: Could not setActive to true: \(error), \(error.userInfo)") + print(error) } + for await voiceGuidance in routeTracker.voiceGuidances { speechSynthesizer.stopSpeaking(at: .word) speechSynthesizer.speak(AVSpeechUtterance(string: voiceGuidance.text)) From 2a6da71560cae168f688ef3e421e3c75675702ea Mon Sep 17 00:00:00 2001 From: Christopher Webb Date: Tue, 25 Nov 2025 10:26:07 -0800 Subject: [PATCH 03/12] add in error handling --- .../NavigateRouteWithReroutingView.Model.swift | 11 +++-------- .../NavigateRouteWithReroutingView.swift | 6 +++++- Shared/Samples/Navigate route/NavigateRouteView.swift | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift index 8dd8984f1..a3b6e51c7 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift @@ -214,15 +214,10 @@ extension NavigateRouteWithReroutingView { /// Speaks a given voice guidance. /// - Parameter voiceGuidance: The `VoiceGuidance`. - func speakVoiceGuidance(_ voiceGuidance: VoiceGuidance) { + func speakVoiceGuidance(_ voiceGuidance: VoiceGuidance) throws { guard !voiceGuidance.text.isEmpty else { return } - do { - try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) - try AVAudioSession.sharedInstance().setActive(true) - } catch let error as NSError { - print(error) - } - + try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) + try AVAudioSession.sharedInstance().setActive(true) let utterance = AVSpeechUtterance(string: voiceGuidance.text) speechSynthesizer.stopSpeaking(at: .word) speechSynthesizer.speak(utterance) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift index 90843a955..a81f3e64c 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift @@ -111,7 +111,11 @@ struct NavigateRouteWithReroutingView: View { group.addTask { @MainActor @Sendable in // Speak new voice guidances from the route tracker. for await voiceGuidance in routeTracker.voiceGuidances { - model.speakVoiceGuidance(voiceGuidance) + do { + try model.speakVoiceGuidance(voiceGuidance) + } catch let error as NSError { + self.error = error + } } } } diff --git a/Shared/Samples/Navigate route/NavigateRouteView.swift b/Shared/Samples/Navigate route/NavigateRouteView.swift index f93ddad92..d41b29325 100644 --- a/Shared/Samples/Navigate route/NavigateRouteView.swift +++ b/Shared/Samples/Navigate route/NavigateRouteView.swift @@ -282,7 +282,7 @@ private extension NavigateRouteView { try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) try AVAudioSession.sharedInstance().setActive(true) } catch let error as NSError { - print(error) + self.error = error } for await voiceGuidance in routeTracker.voiceGuidances { From b63a74cf760b11d4297fad89aee3c62ca4d8454d Mon Sep 17 00:00:00 2001 From: Christopher Webb Date: Tue, 25 Nov 2025 12:37:46 -0800 Subject: [PATCH 04/12] update to fix missed edit --- .../NavigateRouteWithReroutingView.Model.swift | 5 +++-- Shared/Samples/Navigate route/NavigateRouteView.swift | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift index a3b6e51c7..3ad93daa9 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift @@ -216,8 +216,9 @@ extension NavigateRouteWithReroutingView { /// - Parameter voiceGuidance: The `VoiceGuidance`. func speakVoiceGuidance(_ voiceGuidance: VoiceGuidance) throws { guard !voiceGuidance.text.isEmpty else { return } - try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) - try AVAudioSession.sharedInstance().setActive(true) + let session = AVAudioSession.sharedInstance() + try session.setCategory(.playback) + try session.setActive(true) let utterance = AVSpeechUtterance(string: voiceGuidance.text) speechSynthesizer.stopSpeaking(at: .word) speechSynthesizer.speak(utterance) diff --git a/Shared/Samples/Navigate route/NavigateRouteView.swift b/Shared/Samples/Navigate route/NavigateRouteView.swift index d41b29325..7e73d2497 100644 --- a/Shared/Samples/Navigate route/NavigateRouteView.swift +++ b/Shared/Samples/Navigate route/NavigateRouteView.swift @@ -279,8 +279,9 @@ private extension NavigateRouteView { /// Monitors the asynchronous stream of voice guidances. private func trackVoiceGuidance() async { do { - try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) - try AVAudioSession.sharedInstance().setActive(true) + let session = AVAudioSession.sharedInstance() + try session.setCategory(.playback) + try session.setActive(true) } catch let error as NSError { self.error = error } From ef7049d906660e3a00f2e7b1906cc0b8fd29538f Mon Sep 17 00:00:00 2001 From: Christopher Webb Date: Tue, 25 Nov 2025 13:02:05 -0800 Subject: [PATCH 05/12] update for code comments --- .../NavigateRouteWithReroutingView.Model.swift | 5 +---- .../NavigateRouteWithReroutingView.swift | 16 +++++++++------- .../Navigate route/NavigateRouteView.swift | 15 ++++++++------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift index 3ad93daa9..0467ad8f4 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift @@ -214,11 +214,8 @@ extension NavigateRouteWithReroutingView { /// Speaks a given voice guidance. /// - Parameter voiceGuidance: The `VoiceGuidance`. - func speakVoiceGuidance(_ voiceGuidance: VoiceGuidance) throws { + func speakVoiceGuidance(_ voiceGuidance: VoiceGuidance) { guard !voiceGuidance.text.isEmpty else { return } - let session = AVAudioSession.sharedInstance() - try session.setCategory(.playback) - try session.setActive(true) let utterance = AVSpeechUtterance(string: voiceGuidance.text) speechSynthesizer.stopSpeaking(at: .word) speechSynthesizer.speak(utterance) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift index a81f3e64c..aa5fb3b71 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift @@ -13,6 +13,7 @@ // limitations under the License. import ArcGIS +import AVFAudio import SwiftUI struct NavigateRouteWithReroutingView: View { @@ -98,7 +99,13 @@ struct NavigateRouteWithReroutingView: View { } .task(id: model.isNavigating) { guard model.isNavigating, let routeTracker = model.routeTracker else { return } - + do { + let session = AVAudioSession.sharedInstance() + try session.setCategory(.playback, mode: .voicePrompt) + try session.setActive(true) + } catch let error as NSError { + self.error = error + } await withTaskGroup(of: Void.self) { group in group.addTask { @MainActor @Sendable in // Handle new tracking statuses from the route tracker. @@ -107,15 +114,10 @@ struct NavigateRouteWithReroutingView: View { await model.updateProgress(using: trackingStatus) } } - group.addTask { @MainActor @Sendable in // Speak new voice guidances from the route tracker. for await voiceGuidance in routeTracker.voiceGuidances { - do { - try model.speakVoiceGuidance(voiceGuidance) - } catch let error as NSError { - self.error = error - } + model.speakVoiceGuidance(voiceGuidance) } } } diff --git a/Shared/Samples/Navigate route/NavigateRouteView.swift b/Shared/Samples/Navigate route/NavigateRouteView.swift index 7e73d2497..90b57a311 100644 --- a/Shared/Samples/Navigate route/NavigateRouteView.swift +++ b/Shared/Samples/Navigate route/NavigateRouteView.swift @@ -234,6 +234,13 @@ private extension NavigateRouteView { /// Starts monitoring multiple asynchronous streams of information. private func startTracking() async { + do { + let session = AVAudioSession.sharedInstance() + try session.setCategory(.playback, mode: .voicePrompt) + try session.setActive(true) + } catch let error as NSError { + self.error = error + } await withTaskGroup(of: Void.self) { group in group.addTask { await self.trackAutoPanMode() } group.addTask { await self.trackStatus() } @@ -278,13 +285,7 @@ private extension NavigateRouteView { /// Monitors the asynchronous stream of voice guidances. private func trackVoiceGuidance() async { - do { - let session = AVAudioSession.sharedInstance() - try session.setCategory(.playback) - try session.setActive(true) - } catch let error as NSError { - self.error = error - } + for await voiceGuidance in routeTracker.voiceGuidances { speechSynthesizer.stopSpeaking(at: .word) From 1198079db6450142ecff5a01673f90ce6d9cd36f Mon Sep 17 00:00:00 2001 From: Christopher Webb <13937686+chriswebb09@users.noreply.github.com> Date: Tue, 25 Nov 2025 13:32:49 -0800 Subject: [PATCH 06/12] Update Shared/Samples/Navigate route/NavigateRouteView.swift Co-authored-by: Destiny Hochhalter <117859673+des12437@users.noreply.github.com> --- Shared/Samples/Navigate route/NavigateRouteView.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Shared/Samples/Navigate route/NavigateRouteView.swift b/Shared/Samples/Navigate route/NavigateRouteView.swift index 90b57a311..47bb8dd69 100644 --- a/Shared/Samples/Navigate route/NavigateRouteView.swift +++ b/Shared/Samples/Navigate route/NavigateRouteView.swift @@ -285,8 +285,6 @@ private extension NavigateRouteView { /// Monitors the asynchronous stream of voice guidances. private func trackVoiceGuidance() async { - - for await voiceGuidance in routeTracker.voiceGuidances { speechSynthesizer.stopSpeaking(at: .word) speechSynthesizer.speak(AVSpeechUtterance(string: voiceGuidance.text)) From fd5d574dfa171084a72d42e5ae26b6ab3bea9195 Mon Sep 17 00:00:00 2001 From: Christopher Webb Date: Wed, 26 Nov 2025 15:23:59 -0800 Subject: [PATCH 07/12] update for comments --- .../NavigateRouteWithReroutingView.Model.swift | 1 + .../NavigateRouteWithReroutingView.swift | 1 + Shared/Samples/Navigate route/NavigateRouteView.swift | 1 + 3 files changed, 3 insertions(+) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift index 0467ad8f4..12ba06628 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.Model.swift @@ -216,6 +216,7 @@ extension NavigateRouteWithReroutingView { /// - Parameter voiceGuidance: The `VoiceGuidance`. func speakVoiceGuidance(_ voiceGuidance: VoiceGuidance) { guard !voiceGuidance.text.isEmpty else { return } + let utterance = AVSpeechUtterance(string: voiceGuidance.text) speechSynthesizer.stopSpeaking(at: .word) speechSynthesizer.speak(utterance) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift index aa5fb3b71..9e4dcdcfb 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift @@ -100,6 +100,7 @@ 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) diff --git a/Shared/Samples/Navigate route/NavigateRouteView.swift b/Shared/Samples/Navigate route/NavigateRouteView.swift index 47bb8dd69..6ea03b18a 100644 --- a/Shared/Samples/Navigate route/NavigateRouteView.swift +++ b/Shared/Samples/Navigate route/NavigateRouteView.swift @@ -235,6 +235,7 @@ 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) From dca6a497c139b0b9ac2c58bc255b5a86059c7fa7 Mon Sep 17 00:00:00 2001 From: Christopher Webb <13937686+chriswebb09@users.noreply.github.com> Date: Wed, 26 Nov 2025 15:53:17 -0800 Subject: [PATCH 08/12] Apply suggestions from code review Co-authored-by: Ting --- .../NavigateRouteWithReroutingView.swift | 2 +- Shared/Samples/Navigate route/NavigateRouteView.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift index 9e4dcdcfb..8b7d5ec9c 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift @@ -104,7 +104,7 @@ struct NavigateRouteWithReroutingView: View { let session = AVAudioSession.sharedInstance() try session.setCategory(.playback, mode: .voicePrompt) try session.setActive(true) - } catch let error as NSError { + } catch { self.error = error } await withTaskGroup(of: Void.self) { group in diff --git a/Shared/Samples/Navigate route/NavigateRouteView.swift b/Shared/Samples/Navigate route/NavigateRouteView.swift index 6ea03b18a..263dd3b03 100644 --- a/Shared/Samples/Navigate route/NavigateRouteView.swift +++ b/Shared/Samples/Navigate route/NavigateRouteView.swift @@ -239,7 +239,7 @@ private extension NavigateRouteView { let session = AVAudioSession.sharedInstance() try session.setCategory(.playback, mode: .voicePrompt) try session.setActive(true) - } catch let error as NSError { + } catch { self.error = error } await withTaskGroup(of: Void.self) { group in From 59eabc03494ada307fb058c94222384037f4aca4 Mon Sep 17 00:00:00 2001 From: Christopher Webb <13937686+chriswebb09@users.noreply.github.com> Date: Wed, 26 Nov 2025 18:32:07 -0800 Subject: [PATCH 09/12] Add voice guidance speaking in navigation view --- .../NavigateRouteWithReroutingView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift index 8b7d5ec9c..f1cb2e2b4 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift @@ -115,6 +115,7 @@ struct NavigateRouteWithReroutingView: View { await model.updateProgress(using: trackingStatus) } } + group.addTask { @MainActor @Sendable in // Speak new voice guidances from the route tracker. for await voiceGuidance in routeTracker.voiceGuidances { From a04d03436102ac08e48a80c913126d2469b0e257 Mon Sep 17 00:00:00 2001 From: Christopher Webb <13937686+chriswebb09@users.noreply.github.com> Date: Wed, 26 Nov 2025 18:32:51 -0800 Subject: [PATCH 10/12] Remove unnecessary whitespace in NavigateRouteWithReroutingView --- .../NavigateRouteWithReroutingView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift index f1cb2e2b4..09eeefb66 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift @@ -115,7 +115,7 @@ struct NavigateRouteWithReroutingView: View { await model.updateProgress(using: trackingStatus) } } - + group.addTask { @MainActor @Sendable in // Speak new voice guidances from the route tracker. for await voiceGuidance in routeTracker.voiceGuidances { From 2ee4d9a4a541708b9c8af6e4d78bdc1a625241c1 Mon Sep 17 00:00:00 2001 From: Christopher Webb <13937686+chriswebb09@users.noreply.github.com> Date: Wed, 26 Nov 2025 18:33:34 -0800 Subject: [PATCH 11/12] Update NavigateRouteWithReroutingView.swift --- .../NavigateRouteWithReroutingView.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift index 09eeefb66..f47ed7017 100644 --- a/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift +++ b/Shared/Samples/Navigate route with rerouting/NavigateRouteWithReroutingView.swift @@ -99,6 +99,7 @@ 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() @@ -107,6 +108,7 @@ struct NavigateRouteWithReroutingView: View { } catch { self.error = error } + await withTaskGroup(of: Void.self) { group in group.addTask { @MainActor @Sendable in // Handle new tracking statuses from the route tracker. From eb82e2f95a9f4807fdf511dc1fa192a60cecf0d3 Mon Sep 17 00:00:00 2001 From: Christopher Webb Date: Wed, 26 Nov 2025 18:37:50 -0800 Subject: [PATCH 12/12] add in change to ar nav --- .../AugmentRealityToNavigateRouteView.ARSceneView.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Shared/Samples/Augment reality to navigate route/AugmentRealityToNavigateRouteView.ARSceneView.swift b/Shared/Samples/Augment reality to navigate route/AugmentRealityToNavigateRouteView.ARSceneView.swift index 5dbdaca35..a53bc0de8 100644 --- a/Shared/Samples/Augment reality to navigate route/AugmentRealityToNavigateRouteView.ARSceneView.swift +++ b/Shared/Samples/Augment reality to navigate route/AugmentRealityToNavigateRouteView.ARSceneView.swift @@ -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() }