From 2ebd92c70a494b0a2153a893651d9e2ec9df81bd Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 26 Jan 2016 16:29:49 +0100 Subject: [PATCH] notifications: fix crash on iOS < 9 --- Classes/LinphoneAppDelegate.m | 49 ++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 20562b87c..d1bda420b 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -102,36 +102,37 @@ } - (UIUserNotificationCategory *)getMessageNotificationCategory { - - UIMutableUserNotificationAction *reply = [[UIMutableUserNotificationAction alloc] init]; - reply.identifier = @"reply"; - reply.title = NSLocalizedString(@"Reply", nil); - reply.activationMode = UIUserNotificationActivationModeForeground; - reply.destructive = NO; - reply.authenticationRequired = YES; - - UIMutableUserNotificationAction *reply_inline = [[UIMutableUserNotificationAction alloc] init]; - - reply_inline.identifier = @"reply_inline"; - reply_inline.title = NSLocalizedString(@"Reply", nil); - reply_inline.activationMode = UIUserNotificationActivationModeBackground; - reply_inline.destructive = NO; - reply_inline.authenticationRequired = NO; - reply_inline.behavior = UIUserNotificationActionBehaviorTextInput; - - UIMutableUserNotificationAction *mark_read = [[UIMutableUserNotificationAction alloc] init]; - mark_read.identifier = @"mark_read"; - mark_read.title = NSLocalizedString(@"Mark Read", nil); - mark_read.activationMode = UIUserNotificationActivationModeBackground; - mark_read.destructive = NO; - mark_read.authenticationRequired = NO; - NSArray *actions; + if ([[UIDevice.currentDevice systemVersion] floatValue] < 9 || [LinphoneManager.instance lpConfigBoolForKey:@"show_msg_in_notif"] == NO) { + + UIMutableUserNotificationAction *reply = [[UIMutableUserNotificationAction alloc] init]; + reply.identifier = @"reply"; + reply.title = NSLocalizedString(@"Reply", nil); + reply.activationMode = UIUserNotificationActivationModeForeground; + reply.destructive = NO; + reply.authenticationRequired = YES; + + UIMutableUserNotificationAction *mark_read = [[UIMutableUserNotificationAction alloc] init]; + mark_read.identifier = @"mark_read"; + mark_read.title = NSLocalizedString(@"Mark Read", nil); + mark_read.activationMode = UIUserNotificationActivationModeBackground; + mark_read.destructive = NO; + mark_read.authenticationRequired = NO; + actions = @[ mark_read, reply ]; } else { // iOS 9 allows for inline reply. We don't propose mark_read in this case + UIMutableUserNotificationAction *reply_inline = [[UIMutableUserNotificationAction alloc] init]; + + reply_inline.identifier = @"reply_inline"; + reply_inline.title = NSLocalizedString(@"Reply", nil); + reply_inline.activationMode = UIUserNotificationActivationModeBackground; + reply_inline.destructive = NO; + reply_inline.authenticationRequired = NO; + reply_inline.behavior = UIUserNotificationActionBehaviorTextInput; + actions = @[ reply_inline ]; }