Commit 0fe90469 by Sebastián Katzer

Move registration for custom dismiss action to UNUserNotificationCenter

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