|
|
@@ -67,7 +67,7 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
*/
|
|
|
- (NSNumber*) id
|
|
|
{
|
|
|
- NSInteger id = [[dict objectForKey:@"id"] integerValue];
|
|
|
+ NSInteger id = [dict[@"id"] integerValue];
|
|
|
|
|
|
return [NSNumber numberWithInteger:id];
|
|
|
}
|
|
|
@@ -89,7 +89,7 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
*/
|
|
|
- (NSString*) title
|
|
|
{
|
|
|
- return [dict objectForKey:@"title"];
|
|
|
+ return dict[@"title"];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -111,7 +111,7 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
*/
|
|
|
- (NSString*) text
|
|
|
{
|
|
|
- return [dict objectForKey:@"text"];
|
|
|
+ return dict[@"text"];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -121,7 +121,7 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
*/
|
|
|
- (BOOL) silent
|
|
|
{
|
|
|
- return [[dict objectForKey:@"silent"] boolValue];
|
|
|
+ return [dict[@"silent"] boolValue];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -131,7 +131,7 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
*/
|
|
|
- (int) priority
|
|
|
{
|
|
|
- return [[dict objectForKey:@"priority"] intValue];
|
|
|
+ return [dict[@"priority"] intValue];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -141,7 +141,7 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
*/
|
|
|
- (NSNumber*) badge
|
|
|
{
|
|
|
- id value = [dict objectForKey:@"badge"];
|
|
|
+ id value = dict[@"badge"];
|
|
|
|
|
|
return (value == NULL) ? NULL : [NSNumber numberWithInt:[value intValue]];
|
|
|
}
|
|
|
@@ -153,14 +153,9 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
*/
|
|
|
- (NSString*) actionGroupId
|
|
|
{
|
|
|
- id actions = [dict objectForKey:@"actions"];
|
|
|
+ id actions = dict[@"actions"];
|
|
|
|
|
|
- if ([actions isKindOfClass:NSString.class])
|
|
|
- return actions;
|
|
|
-
|
|
|
- NSString* value = [dict objectForKey:@"actionGroupId"];
|
|
|
-
|
|
|
- return value.length ? value : kAPPGeneralCategory;
|
|
|
+ return ([actions isKindOfClass:NSString.class]) ? actions : kAPPGeneralCategory;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -170,7 +165,7 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
*/
|
|
|
- (UNNotificationSound*) sound
|
|
|
{
|
|
|
- NSString* path = [dict objectForKey:@"sound"];
|
|
|
+ NSString* path = dict[@"sound"];
|
|
|
NSString* file;
|
|
|
|
|
|
if ([path isKindOfClass:NSNumber.class]) {
|
|
|
@@ -198,7 +193,7 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
*/
|
|
|
- (NSArray<UNNotificationAttachment *> *) attachments
|
|
|
{
|
|
|
- NSArray* paths = [dict objectForKey:@"attachments"];
|
|
|
+ NSArray* paths = dict[@"attachments"];
|
|
|
NSMutableArray* attachments = [[NSMutableArray alloc] init];
|
|
|
|
|
|
if (!paths)
|
|
|
@@ -221,69 +216,6 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
return attachments;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Additional actions for the notification.
|
|
|
- *
|
|
|
- * @return [ NSArray* ]
|
|
|
- */
|
|
|
-- (NSArray<UNNotificationAction *> *) actions
|
|
|
-{
|
|
|
- NSArray* items = [dict objectForKey:@"actions"];
|
|
|
- NSMutableArray* actions = [[NSMutableArray alloc] init];
|
|
|
-
|
|
|
- if (!items)
|
|
|
- return actions;
|
|
|
-
|
|
|
- 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;
|
|
|
- }
|
|
|
-
|
|
|
- if ([[item objectForKey:@"ui"] isEqualToString:@"decline"]) {
|
|
|
- options = options | UNNotificationActionOptionDestructive;
|
|
|
- }
|
|
|
-
|
|
|
- if ([[item objectForKey:@"needsAuth"] boolValue]) {
|
|
|
- options = options | UNNotificationActionOptionAuthenticationRequired;
|
|
|
- }
|
|
|
-
|
|
|
- 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);
|
|
|
- }
|
|
|
-
|
|
|
- if (action) {
|
|
|
- [actions addObject:action];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return actions;
|
|
|
-}
|
|
|
-
|
|
|
#pragma mark -
|
|
|
#pragma mark Public
|
|
|
|
|
|
@@ -315,7 +247,7 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
*/
|
|
|
- (NSDictionary*) userInfo
|
|
|
{
|
|
|
- if ([dict objectForKey:@"updatedAt"]) {
|
|
|
+ if (dict[@"updatedAt"]) {
|
|
|
NSMutableDictionary* data = [dict mutableCopy];
|
|
|
|
|
|
[data removeObjectForKey:@"updatedAt"];
|
|
|
@@ -331,7 +263,7 @@ static NSInteger WEEKDAYS[8] = { 0, 2, 3, 4, 5, 6, 7, 1 };
|
|
|
|
|
|
- (id) valueForTriggerOption:(NSString*)key
|
|
|
{
|
|
|
- return [[dict objectForKey:@"trigger"] objectForKey:key];
|
|
|
+ return dict[@"trigger"][key];
|
|
|
}
|
|
|
|
|
|
/**
|