From d61966f4e21361e7a93bd2c74740bb09268bc332 Mon Sep 17 00:00:00 2001 From: Ivan Sein Date: Wed, 22 Nov 2017 22:11:45 +0100 Subject: [PATCH] Change PN alert depending on notification type. Signed-off-by: Ivan Sein --- .../NotificationService.m | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/NotificationServiceExtension/NotificationService.m b/NotificationServiceExtension/NotificationService.m index 152f8cb3..a21e69da 100644 --- a/NotificationServiceExtension/NotificationService.m +++ b/NotificationServiceExtension/NotificationService.m @@ -42,13 +42,21 @@ if (decryptedMessage) { NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding]; id messageJSON = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + NSString *app = [messageJSON objectForKey:@"app"]; + NSString *type = [messageJSON objectForKey:@"type"]; + NSString *subject = [messageJSON objectForKey:@"subject"]; - decryptedMessage = [messageJSON objectForKey:@"subject"]; - self.bestAttemptContent.body = decryptedMessage; - - NSString *appId = [messageJSON objectForKey:@"app"]; - if ([appId isEqualToString:@"spreed"]) { - self.bestAttemptContent.title = @"Talk notification 📞"; + if ([app isEqualToString:@"spreed"]) { + self.bestAttemptContent.title = @""; + if ([type isEqualToString:@"call"]) { + self.bestAttemptContent.body = [NSString stringWithFormat:@"📞 %@", subject]; + } else if ([type isEqualToString:@"room"]) { + self.bestAttemptContent.body = [NSString stringWithFormat:@"🔔 %@", subject]; + } else if ([type isEqualToString:@"chat"]) { + self.bestAttemptContent.body = [NSString stringWithFormat:@"💬 %@", subject]; + } else { + self.bestAttemptContent.body = subject; + } } }