|
@@ -541,36 +541,44 @@ PKPushRegistry *pushRegistry;
|
|
|
|
|
|
NSString *app = [json objectForKey:@"app"];
|
|
|
NSString *subject = [json objectForKey:@"subject"];
|
|
|
- //NSInteger notificationId = [[json objectForKey:@"nid"] integerValue];
|
|
|
-
|
|
|
- NSURL *url = [NSURL URLWithString:result.url];
|
|
|
- NSString *domain = [url host];
|
|
|
+ NSInteger notificationId = [[json objectForKey:@"nid"] integerValue];
|
|
|
+ BOOL delete = [[json objectForKey:@"delete"] boolValue];
|
|
|
+
|
|
|
+ if (!delete && subject) {
|
|
|
+
|
|
|
+ NSURL *url = [NSURL URLWithString:result.url];
|
|
|
+ NSString *domain = [url host];
|
|
|
|
|
|
- if ([app isEqualToString:@"spreed"]) {
|
|
|
- content.title = @"Nextcloud Talk";
|
|
|
- if (results.count > 1) { content.subtitle = [NSString stringWithFormat:@"%@ (%@)", result.displayName, domain]; }
|
|
|
- if (subject) { content.body = subject; }
|
|
|
- } else {
|
|
|
- if (results.count > 1) { content.title = [NSString stringWithFormat:@"%@ (%@)", result.displayName, domain]; }
|
|
|
- if (subject) { content.body = subject; }
|
|
|
- }
|
|
|
+ if ([app isEqualToString:@"spreed"]) {
|
|
|
+ content.title = @"Nextcloud Talk";
|
|
|
+ if (results.count > 1) { content.subtitle = [NSString stringWithFormat:@"%@ (%@)", result.displayName, domain]; }
|
|
|
+ if (subject) { content.body = subject; }
|
|
|
+ } else {
|
|
|
+ if (results.count > 1) { content.title = [NSString stringWithFormat:@"%@ (%@)", result.displayName, domain]; }
|
|
|
+ if (subject) { content.body = subject; }
|
|
|
+ }
|
|
|
|
|
|
- content.sound = [UNNotificationSound defaultSound];
|
|
|
+ content.sound = [UNNotificationSound defaultSound];
|
|
|
|
|
|
- /*
|
|
|
- [[OCNetworking sharedManager] getServerNotification:result.url notificationId:notificationId completion:^(NSDictionary *json, NSString *message, NSInteger errorCode) {
|
|
|
- //
|
|
|
- }];
|
|
|
- */
|
|
|
+ /*
|
|
|
+ [[OCNetworking sharedManager] getServerNotification:result.url notificationId:notificationId completion:^(NSDictionary *json, NSString *message, NSInteger errorCode) {
|
|
|
+ //
|
|
|
+ }];
|
|
|
+ */
|
|
|
|
|
|
- NSString *identifier = [NSString stringWithFormat:@"Notification-%@", [NSDate new]];
|
|
|
+ NSString *identifier = [NSString stringWithFormat:@"Notification-%@", [NSDate new]];
|
|
|
|
|
|
- UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:0.1 repeats:NO];
|
|
|
- UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
|
|
|
+ UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:0.1 repeats:NO];
|
|
|
+ UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
|
|
|
|
|
|
- [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:nil];
|
|
|
-
|
|
|
- break;
|
|
|
+ [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:nil];
|
|
|
+
|
|
|
+ } else if (delete) {
|
|
|
+
|
|
|
+ [[OCNetworking sharedManager] deletingServerNotification:result.url notificationId:notificationId completion:^(NSString *message, NSInteger errorCode) {
|
|
|
+ NSLog(@"Deleting Server Notification error: %ld", errorCode);
|
|
|
+ }];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|