blob: bd33a2059ed5d162c32064420a1b87147f0c16dd (
plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
//
// CDVPinDialog.m
// HelloWorld
//
//
//
#import "CDVPinDialog.h"
@implementation CDVPinDialog
- (void)prompt:(CDVInvokedUrlCommand*)command
{
self.callbackId = command.callbackId;
NSString* message = [command argumentAtIndex:0];
NSString* title = [command argumentAtIndex:1];
NSArray* buttons = [command argumentAtIndex:2];
UIAlertView* alertView = [[UIAlertView alloc]
initWithTitle:title
message:message
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
//alertView.callbackId = callbackId;
int count = [buttons count];
for (int n = 0; n < count; n++) {
[alertView addButtonWithTitle:[buttons objectAtIndex:n]];
}
alertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
UITextField* textField = [alertView textFieldAtIndex:0];
[alertView show];
[textField resignFirstResponder];
[textField setKeyboardType:UIKeyboardTypeNumberPad];
[textField becomeFirstResponder];
}
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
CDVPluginResult* result;
NSString* value0 = [[alertView textFieldAtIndex:0] text];
NSDictionary* info = @{
@"buttonIndex":@(buttonIndex + 1),
@"input1":(value0 ? value0 : [NSNull null])
};
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info];
[self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
}
@end
|