Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Fix for dictation not working on iOS 17 (#922)
Browse files Browse the repository at this point in the history
  • Loading branch information
Velin92 authored Jan 12, 2024
1 parent 9a8cb9c commit ab19533
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,22 @@ public class WysiwygTextView: UITextView {
private func commonInit() {
contentMode = .redraw
NotificationCenter.default.addObserver(self,
selector: #selector(textInputCurrentInputModeDidChange),
name: UITextInputMode.currentInputModeDidChangeNotification,
selector: #selector(dictationDidStart),
name: .init("UIKeyboardDidBeginDictationNotification"),
object: nil)
}

@objc private func textInputCurrentInputModeDidChange(notification: Notification) {
// We don't care about the input mode if this is not the first responder
guard isFirstResponder else {
return
}

guard let inputMode = textInputMode?.primaryLanguage,
inputMode == "dictation" else {
isDictationRunning = false
return
}
@objc private func dictationDidStart(notification: Notification) {
isDictationRunning = true
}

override public func dictationRecordingDidEnd() {
super.dictationRecordingDidEnd()
isDictationRunning = false
}

override public func dictationRecognitionFailed() {
super.dictationRecognitionFailed()
isDictationRunning = false
}

Expand Down

0 comments on commit ab19533

Please sign in to comment.