Commit 19d5b97a by Sebastián Katzer

Proper action identifier handling in delegate

parent ebee0373
...@@ -626,16 +626,18 @@ ...@@ -626,16 +626,18 @@
withCompletionHandler:(void (^)())completionHandler withCompletionHandler:(void (^)())completionHandler
{ {
UNNotificationRequest* notification = response.notification.request; UNNotificationRequest* notification = response.notification.request;
NSString* action = response.actionIdentifier;
NSString* event = action;
[self fireEvent:@"click" notification:notification]; if ([action isEqualToString:UNNotificationDefaultActionIdentifier]) {
event = @"click";
}
if ([action isEqualToString:UNNotificationDismissActionIdentifier]) {
event = @"clear";
}
// if ([notification.options isRepeating]) { [self fireEvent:event notification:notification];
// [_center clearNotification:notification];
// [self fireEvent:@"clear" notification:notification];
// } else {
// [_center cancelNotification:notification];
// [self fireEvent:@"cancel" notification:notification];
// }
completionHandler(); completionHandler();
} }
...@@ -653,6 +655,15 @@ ...@@ -653,6 +655,15 @@
_center = [UNUserNotificationCenter currentNotificationCenter]; _center = [UNUserNotificationCenter currentNotificationCenter];
_center.delegate = self; _center.delegate = self;
UNNotificationCategory* generalCategory = [UNNotificationCategory
categoryWithIdentifier:@"GENERAL"
actions:@[]
intentIdentifiers:@[]
options:UNNotificationCategoryOptionCustomDismissAction];
// Register the notification categories.
[_center setNotificationCategories:[NSSet setWithObjects:generalCategory, nil]];
} }
#pragma mark - #pragma mark -
......
...@@ -65,6 +65,7 @@ static char optionsKey; ...@@ -65,6 +65,7 @@ static char optionsKey;
self.body = options.text; self.body = options.text;
self.sound = options.sound; self.sound = options.sound;
self.badge = options.badge; self.badge = options.badge;
self.categoryIdentifier = @"GENERAL";
} }
#pragma mark - #pragma mark -
......
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