Commit 0d85c72c by Sebastián Katzer

Add support for text input actions

parent 82eb458e
......@@ -693,12 +693,12 @@
- (void) fireEvent:(NSString*)event
notification:(UNNotificationRequest*)request
{
NSString *js, *args;
NSString *js;
NSString *appState = [self applicationState];
NSString *params = [NSString stringWithFormat:@"\"%@\"", appState];
if (request) {
args = [request encodeToJSON];
NSString *args = [request encodeToJSON];
params = [NSString stringWithFormat:@"%@,'%@'", args, appState];
}
......
......@@ -212,7 +212,10 @@
for (NSDictionary* item in items) {
NSString* id = [item objectForKey:@"id"];
NSString* title = [item objectForKey:@"title"];
NSString* type = [item objectForKey:@"type"];
UNNotificationActionOptions options = UNNotificationActionOptionNone;
UNNotificationAction* action;
if ([[item objectForKey:@"launch"] boolValue]) {
options = UNNotificationActionOptionForeground;
......@@ -226,12 +229,31 @@
options = options | UNNotificationActionOptionAuthenticationRequired;
}
UNNotificationAction* action;
action = [UNNotificationAction actionWithIdentifier:id
title:title
options:options];
if ([type isEqualToString:@"input"]) {
NSString* submitTitle = [item objectForKey:@"submitTitle"];
NSString* placeholder = [item objectForKey:@"emptyText"];
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;
......
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