Commit 0fe90469 by Sebastián Katzer

Move registration for custom dismiss action to UNUserNotificationCenter

parent 19d5b97a
...@@ -631,8 +631,7 @@ ...@@ -631,8 +631,7 @@
if ([action isEqualToString:UNNotificationDefaultActionIdentifier]) { if ([action isEqualToString:UNNotificationDefaultActionIdentifier]) {
event = @"click"; event = @"click";
} } else
if ([action isEqualToString:UNNotificationDismissActionIdentifier]) { if ([action isEqualToString:UNNotificationDismissActionIdentifier]) {
event = @"clear"; event = @"clear";
} }
...@@ -655,15 +654,7 @@ ...@@ -655,15 +654,7 @@
_center = [UNUserNotificationCenter currentNotificationCenter]; _center = [UNUserNotificationCenter currentNotificationCenter];
_center.delegate = self; _center.delegate = self;
[_center registerGeneralNotificationCategory];
UNNotificationCategory* generalCategory = [UNNotificationCategory
categoryWithIdentifier:@"GENERAL"
actions:@[]
intentIdentifiers:@[]
options:UNNotificationCategoryOptionCustomDismissAction];
// Register the notification categories.
[_center setNotificationCategories:[NSSet setWithObjects:generalCategory, nil]];
} }
#pragma mark - #pragma mark -
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
@interface UNUserNotificationCenter (APPLocalNotification) @interface UNUserNotificationCenter (APPLocalNotification)
extern NSString * const kAPPGeneralCategory;
typedef NS_ENUM(NSUInteger, APPNotificationType) { typedef NS_ENUM(NSUInteger, APPNotificationType) {
NotifcationTypeAll = 0, NotifcationTypeAll = 0,
NotifcationTypeScheduled = 1, NotifcationTypeScheduled = 1,
...@@ -36,6 +38,8 @@ typedef NS_ENUM(NSUInteger, APPNotificationType) { ...@@ -36,6 +38,8 @@ typedef NS_ENUM(NSUInteger, APPNotificationType) {
@property (readonly, getter=getNotifications) NSArray* localNotifications; @property (readonly, getter=getNotifications) NSArray* localNotifications;
@property (readonly, getter=getNotificationIds) NSArray* localNotificationIds; @property (readonly, getter=getNotificationIds) NSArray* localNotificationIds;
- (void) registerGeneralNotificationCategory;
// List of all notification IDs from given type // List of all notification IDs from given type
- (NSArray*) getNotificationIdsByType:(APPNotificationType)type; - (NSArray*) getNotificationIdsByType:(APPNotificationType)type;
......
...@@ -26,9 +26,32 @@ ...@@ -26,9 +26,32 @@
@import UserNotifications; @import UserNotifications;
NSString * const kAPPGeneralCategory = @"GENERAL";
@implementation UNUserNotificationCenter (APPLocalNotification) @implementation UNUserNotificationCenter (APPLocalNotification)
#pragma mark - #pragma mark -
#pragma mark NotificationCategory
/**
* Register general notification category to listen for dismiss actions.
*
* @return [ Void ]
*/
- (void) registerGeneralNotificationCategory
{
UNNotificationCategory* category;
category = [UNNotificationCategory
categoryWithIdentifier:@"GENERAL"
actions:@[]
intentIdentifiers:@[]
options:UNNotificationCategoryOptionCustomDismissAction];
[self setNotificationCategories:[NSSet setWithObjects:category, nil]];
}
#pragma mark -
#pragma mark LocalNotifications #pragma mark LocalNotifications
/** /**
......
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