/
KeyboardCommand.m
38 lines (25 loc) · 1.09 KB
/
KeyboardCommand.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// Created by pete on 5/20/12.
//
// To change the template use AppCode | Preferences | File Templates.
//
#import "KeyboardCommand.h"
#import "JSON.h"
#import "PublicAutomation/PublicAutomation.h"
#import "FranklyProtocolHelper.h"
@implementation KeyboardCommand {
}
- (NSString *)generateKeyboardNotPresentErrorResponse {
return [FranklyProtocolHelper generateErrorResponseWithReason:@"keyboard not present"
andDetails:@"The iOS keyboard is not currently present, so Frank can't use it so simulate typing. You might want to simulate a tap on the thing you want to type into first."];
}
- (NSString *)handleCommandWithRequestBody:(NSString *)requestBody {
NSDictionary *requestCommand = [requestBody JSONValue];
NSString *textToType = [requestCommand objectForKey:@"text_to_type"];
if( ![UIAutomationBridge checkForKeyboard] ){
return [self generateKeyboardNotPresentErrorResponse];
}
[UIAutomationBridge typeIntoKeyboard:textToType];
return [FranklyProtocolHelper generateSuccessResponseWithoutResults];
}
@end