Skip to content

Commit c0a63d5

Browse files
davutclaude
andcommitted
Fix repeated speech recognition permission prompts
Check authorizationStatus() before calling requestAuthorization() so the system prompt only appears once (when status is notDetermined). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dc6d00d commit c0a63d5

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

Wirdi/Wirdi/SpeechRecognizer.swift

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,21 @@ class SpeechRecognizer {
9090
retryCount = 0
9191
error = nil
9292

93-
SFSpeechRecognizer.requestAuthorization { [weak self] status in
94-
DispatchQueue.main.async {
95-
switch status {
96-
case .authorized:
97-
self?.beginRecognition()
98-
default:
99-
self?.error = "Speech recognition not authorized"
93+
let status = SFSpeechRecognizer.authorizationStatus()
94+
if status == .authorized {
95+
beginRecognition()
96+
} else if status == .notDetermined {
97+
SFSpeechRecognizer.requestAuthorization { [weak self] status in
98+
DispatchQueue.main.async {
99+
if status == .authorized {
100+
self?.beginRecognition()
101+
} else {
102+
self?.error = "Speech recognition not authorized"
103+
}
100104
}
101105
}
106+
} else {
107+
error = "Speech recognition not authorized"
102108
}
103109
}
104110

0 commit comments

Comments
 (0)