Commit 0d85c72c by Sebastián Katzer

Add support for text input actions

parent 82eb458e
...@@ -693,12 +693,12 @@ ...@@ -693,12 +693,12 @@
- (void) fireEvent:(NSString*)event - (void) fireEvent:(NSString*)event
notification:(UNNotificationRequest*)request notification:(UNNotificationRequest*)request
{ {
NSString *js, *args; NSString *js;
NSString *appState = [self applicationState]; NSString *appState = [self applicationState];
NSString *params = [NSString stringWithFormat:@"\"%@\"", appState]; NSString *params = [NSString stringWithFormat:@"\"%@\"", appState];
if (request) { if (request) {
args = [request encodeToJSON]; NSString *args = [request encodeToJSON];
params = [NSString stringWithFormat:@"%@,'%@'", args, appState]; params = [NSString stringWithFormat:@"%@,'%@'", args, appState];
} }
......
...@@ -212,7 +212,10 @@ ...@@ -212,7 +212,10 @@
for (NSDictionary* item in items) { for (NSDictionary* item in items) {
NSString* id = [item objectForKey:@"id"]; NSString* id = [item objectForKey:@"id"];
NSString* title = [item objectForKey:@"title"]; NSString* title = [item objectForKey:@"title"];
NSString* type = [item objectForKey:@"type"];
UNNotificationActionOptions options = UNNotificationActionOptionNone; UNNotificationActionOptions options = UNNotificationActionOptionNone;
UNNotificationAction* action;
if ([[item objectForKey:@"launch"] boolValue]) { if ([[item objectForKey:@"launch"] boolValue]) {
options = UNNotificationActionOptionForeground; options = UNNotificationActionOptionForeground;
...@@ -226,12 +229,31 @@ ...@@ -226,12 +229,31 @@
options = options | UNNotificationActionOptionAuthenticationRequired; options = options | UNNotificationActionOptionAuthenticationRequired;
} }
UNNotificationAction* action; if ([type isEqualToString:@"input"]) {
action = [UNNotificationAction actionWithIdentifier:id NSString* submitTitle = [item objectForKey:@"submitTitle"];
title:title NSString* placeholder = [item objectForKey:@"emptyText"];
options:options];
if (!submitTitle.length) {
submitTitle = @"Submit";
}
action = [UNTextInputNotificationAction actionWithIdentifier:id
title:title
options:options
textInputButtonTitle:submitTitle
textInputPlaceholder:placeholder];
} else
if (!type.length || [type isEqualToString:@"button"]) {
action = [UNNotificationAction actionWithIdentifier:id
title:title
options:options];
} else {
NSLog(@"Unknown action type: %@", type);
}
[actions addObject:action]; if (action) {
[actions addObject:action];
}
} }
return actions; return actions;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment