-
Notifications
You must be signed in to change notification settings - Fork 12
[Fix] Allow navigation to be spoken when device is on silent #729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v.next
Are you sure you want to change the base?
Conversation
yo1995
left a comment
There was a problem hiding this 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.
| do { | ||
| try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) | ||
| try AVAudioSession.sharedInstance().setActive(true) | ||
| } catch let error as NSError { | ||
| print(error) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Can you try if
voicePromptneeds to be set with thesetCategory(_:mode:options:)method?- If so, does the mode need to be reset to default after the sample is closed?
- 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?
- The samples app doesn't print error. It uses
errorAlert(presentingError:)to present errors. Handle the error in the view. - Once addressed the feedback, can you add some comments to explain what do these changes do? Thanks.
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. |
| do { | ||
| try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) | ||
| try AVAudioSession.sharedInstance().setActive(true) | ||
| } catch let error as NSError { | ||
| print(error) | ||
| } |
There was a problem hiding this comment.
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
}
Description
This is a fix so that the sample speaks navigation instructions when the device is on silent
Linked Issue(s)
swift/issues/7556