Skip to content

Conversation

@chriswebb09
Copy link
Collaborator

Description

This is a fix so that the sample speaks navigation instructions when the device is on silent

Linked Issue(s)

  • swift/issues/7556

@chriswebb09 chriswebb09 self-assigned this Nov 20, 2025
@chriswebb09 chriswebb09 marked this pull request as ready for review November 24, 2025 18:13
Copy link
Collaborator

@yo1995 yo1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have an iOS 26 device.
Is this problem reproducible on iOS 26 Simulator? I turned on silent mode on simulator, and with or without the fix, the voice guidance are both announced.

Comment on lines +219 to +224
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback)
try AVAudioSession.sharedInstance().setActive(true)
} catch let error as NSError {
print(error)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can you try if voicePrompt needs to be set with the setCategory(_:mode:options:) method?
    1. If so, does the mode need to be reset to default after the sample is closed?
  2. The method is called each time when a voice guidance is available. Instead of setting the shared audio session for each voice guidance, can you set it only once, before the turn-by-turn navigation starts?
  3. The samples app doesn't print error. It uses errorAlert(presentingError:) to present errors. Handle the error in the view.
  4. Once addressed the feedback, can you add some comments to explain what do these changes do? Thanks.

@des12437
Copy link
Contributor

I don't have an iOS 26 device. Is this problem reproducible on iOS 26 Simulator? I turned on silent mode on simulator, and with or without the fix, the voice guidance are both announced.

I tested this on an iOS 26 device and without the fix the directions are not spoken when the device is on silent mode, with the fix the directions are spoken regardless.

Comment on lines +219 to +224
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback)
try AVAudioSession.sharedInstance().setActive(true)
} catch let error as NSError {
print(error)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the other feedback, a variable can be created for the session, the .playback category is implicit, and the error can be set so it is shown in the error alert UI:

do {
     let session = AVAudioSession.sharedInstance()
     try session.setCategory(.playback)
     try session.setActive(true)
} catch let error as NSError {
     self.error = error
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants