7

In my Apple Watch app I need to input text, so is there any way to input text in my app with voiceOver or any other ways?

As I have seen none of the objects in WKInterfaceController support editable text inputs like UITextfield or UITextview.

5 Answers 5

8

The above answer has no code, just a link to Apple's awesome XD documentation. You can launch a speech recognition menu with some voice options using this code (WatchOS2, iOS 9.2.1):

//LAUNCH VOICE DICTATION (physical device only)
    func launchVoiceDictationMenu(){
        self.presentTextInputControllerWithSuggestions(["Hello","Goodbye","Hey"], allowedInputMode: WKTextInputMode.Plain,
            completion:{(results) -> Void in
                let aResult = results?[0] as? String
                print(aResult)
        })
    }
Sign up to request clarification or add additional context in comments.

Comments

5

Update with swift 3 watchOS 3 Scribble mode

presentTextInputController(withSuggestions: ["watchOS3"], allowedInputMode:   WKTextInputMode.plain) { (arr: [Any]?) in
        print(arr ?? "Not find")
    }

Comments

4

With watchOS 3 welcome the new "scribble" mode

[self presentTextInputControllerWithSuggestions:@[@"watchOS3"]; allowedInputMode:WKTextInputModePlain completion:^(NSArray *array){

    if (array != nil) {

        for (int i=0; i<[array count]; i++) {

            NSString *str = [array objectAtIndex:0];

            NSLog(@"%@",str);
        }

    }

}];

enter image description here enter image description here

Comments

3

Yes, you can input text in Apple Watch using dictation (the watch has a microphone) or by selecting an emoji right on the screen. From Apple Documentation:

WatchKit provides a standard modal interface for retrieving text input from the user. When presented, the interface allows the user to enter text via dictation or to select from a standard set of phrases or emoji.

4 Comments

Thanks Nikos, it helps a lot. If possible please share the sample of code.
@AbhishekSinha the link to apple documentation has also code samples for text input :-)
@AbhishekSinha I wrote a quick blog post that might help you: fiveminutewatchkit.com/blog/2015/3/15/…
A nice tutorial for text input using WatchKit natashatherobot.com/watchkit-text-input-dictation-api
3

Swift 4

@IBAction func ReplyWithTextInputController(){

    let phrases = ["OK", "I'm busy.", "Where are you?", "Thanks."]

    presentTextInputController(withSuggestions: phrases,
                                    allowedInputMode: WKTextInputMode.allowEmoji, completion: { (result) -> Void in

                                        guard let choice = result else {
                                            return
                                        }
                                        let suggestion = choice[0]
                                        print(suggestion)

                        })

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.