From a7e7093163babbab868b5138d7c5df8042e8abbc Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Fri, 3 Oct 2014 16:15:46 +0200 Subject: [PATCH] Limit "category" for local notifications with devices >= ios8 --- Classes/LinphoneAppDelegate.m | 43 +++++++++++++++++++---------------- Classes/LinphoneManager.m | 8 +++++-- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 4c4b62052..3b418cec7 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -425,26 +425,29 @@ } - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void (^)())completionHandler { - LinphoneCore* lc = [LinphoneManager getLc]; - [LinphoneLogger log:LinphoneLoggerLog format:@"%@", NSStringFromSelector(_cmd)]; - if( [notification.category isEqualToString:@"incoming_call"]) { - if( [identifier isEqualToString:@"answer"] ){ - // use the standard handler - [self application:application didReceiveLocalNotification:notification]; - } else if( [identifier isEqualToString:@"decline"] ){ - LinphoneCall* call = linphone_core_get_current_call(lc); - if( call ) linphone_core_decline_call(lc, call, LinphoneReasonDeclined); - } - } else if( [notification.category isEqualToString:@"incoming_msg"] ){ - if( [identifier isEqualToString:@"reply"] ){ - // use the standard handler - [self application:application didReceiveLocalNotification:notification]; - } else if( [identifier isEqualToString:@"mark_read"] ){ - NSString* from = [notification.userInfo objectForKey:@"from"]; - LinphoneChatRoom* room = linphone_core_get_or_create_chat_room(lc, [from UTF8String]); - if( room ){ - linphone_chat_room_mark_as_read(room); - [[PhoneMainView instance] updateApplicationBadgeNumber]; + if( [[UIDevice currentDevice].systemVersion floatValue] >= 8){ + + LinphoneCore* lc = [LinphoneManager getLc]; + [LinphoneLogger log:LinphoneLoggerLog format:@"%@", NSStringFromSelector(_cmd)]; + if( [notification.category isEqualToString:@"incoming_call"]) { + if( [identifier isEqualToString:@"answer"] ){ + // use the standard handler + [self application:application didReceiveLocalNotification:notification]; + } else if( [identifier isEqualToString:@"decline"] ){ + LinphoneCall* call = linphone_core_get_current_call(lc); + if( call ) linphone_core_decline_call(lc, call, LinphoneReasonDeclined); + } + } else if( [notification.category isEqualToString:@"incoming_msg"] ){ + if( [identifier isEqualToString:@"reply"] ){ + // use the standard handler + [self application:application didReceiveLocalNotification:notification]; + } else if( [identifier isEqualToString:@"mark_read"] ){ + NSString* from = [notification.userInfo objectForKey:@"from"]; + LinphoneChatRoom* room = linphone_core_get_or_create_chat_room(lc, [from UTF8String]); + if( room ){ + linphone_chat_room_mark_as_read(room); + [[PhoneMainView instance] updateApplicationBadgeNumber]; + } } } } diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 2c466a544..e08159ef3 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -670,7 +670,9 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char data->timer = [NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(localNotifContinue:) userInfo:data->notification repeats:TRUE]; data->notification.repeatInterval = 0; - data->notification.category = @"incoming_call"; + if( [[UIDevice currentDevice].systemVersion floatValue] >= 8){ + data->notification.category = @"incoming_call"; + } data->notification.alertBody =[NSString stringWithFormat:NSLocalizedString(@"IC_MSG",nil), address]; data->notification.alertAction = NSLocalizedString(@"Answer", nil); data->notification.soundName = @"shortring.caf"; @@ -895,7 +897,9 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo UILocalNotification* notif = [[[UILocalNotification alloc] init] autorelease]; if (notif) { notif.repeatInterval = 0; - notif.category = @"incoming_msg"; + if( [[UIDevice currentDevice].systemVersion floatValue] >= 8){ + notif.category = @"incoming_msg"; + } notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_MSG",nil), address]; notif.alertAction = NSLocalizedString(@"Show", nil); notif.soundName = @"msg.caf";