According to Apple's doc of WKInterfaceController you can let user to dictate text preseting a new interface controller in this very simple way:
self.presentTextInputControllerWithSuggestions(["suggestion 1", "suggestion 2"] allowedInputMode: .Plain, completion: { (answers) -> Void in
if reply && reply.count > 0 {
if let answer = answers[0] as? String {
println("\answer")
}
}
})
as explained here.
I have seen that Amazon App for Apple Watch let you search for products by tapping the search icon directly
So you get into the Dictation in one step
Through the WKInterfaceController
method, we will get something different
Which Apple's API Amazon app is using to enable dictation in this way?
(UPDATE) I have just find out that it's super easy as explained here
So the final solution I came out was this
- (void) table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex {
if (rowIndex==0) { // handle manual selection
__weak MainInterfaceController *weakSelf = self;
[self presentTextInputControllerWithSuggestions:nil allowedInputMode:WKTextInputModePlain completion:^(NSArray *results) {
if(results && [results count]>0) {
NSString *inputText=nil;
for(NSString *input in results) {
NSLog(@"Input %@", input);
inputText=input;
break;
}
if(inputText!=nil && [inputText length]>0) {
[weakSelf pushControllerWithName:@"Search" context:
[NSDictionary dictionaryWithObjectsAndKeys:
inputText, @"query", nil]
];
}
} else {
NSLog(@"No input provided");
}
}];
}}
Set the mode to
.Plain
and don't provide any suggestions.