diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index fc3cb4c7e..c64e089ad 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -469,15 +469,7 @@ } } - if (callId) { - int index = -1; - NSDictionary *dict = LinphoneManager.instance.pushDict; - if ([[dict allKeys] containsObject:callId]) { - index = [(NSNumber *)[LinphoneManager.instance.pushDict objectForKey:callId] intValue] + 1; - } else { - index = 1; - } - [LinphoneManager.instance.pushDict setValue:[NSNumber numberWithInt:index] forKey:callId]; + if (callId && [self addLongTaskIDforCallID:callId]) { if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground && loc_key && index > 0) { if ([loc_key isEqualToString:@"IC_MSG"]) { @@ -492,6 +484,17 @@ LOGI(@"Notification %@ processed", userInfo.description); } +- (BOOL)addLongTaskIDforCallID:(NSString *)callId { + NSDictionary *dict = LinphoneManager.instance.pushDict; + if ([[dict allKeys] indexOfObject:callId] != NSNotFound) { + return FALSE; + } + + LOGI(@"Adding long running task for call id : %@ with index : 1", callId); + [dict setValue:[NSNumber numberWithInt:1] forKey:callId]; + return TRUE; +} + - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { LOGI(@"%@ : %@", NSStringFromSelector(_cmd), userInfo); diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 8a497898c..751b994d9 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -668,6 +668,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char LinphoneCallLog *callLog = linphone_call_get_call_log(call); NSString *callId = [NSString stringWithUTF8String:linphone_call_log_get_call_id(callLog)]; int index = [(NSNumber *)[_pushDict objectForKey:callId] intValue] - 1; + LOGI(@"Decrementing index of long running task for call id : %@ with index : %d", callId, index); [_pushDict setValue:[NSNumber numberWithInt:index] forKey:callId]; BOOL need_bg_task = FALSE; for (NSString *key in [_pushDict allKeys]) { @@ -1190,6 +1191,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char NSString *remote_uri = [NSString stringWithUTF8String:c_address]; ms_free(c_address); int index = [(NSNumber *)[_pushDict objectForKey:callID] intValue] - 1; + LOGI(@"Decrementing index of long running task for call id : %@ with index : %d", callID, index); [_pushDict setValue:[NSNumber numberWithInt:index] forKey:callID]; BOOL need_bg_task = FALSE; for (NSString *key in [_pushDict allKeys]) { @@ -1352,7 +1354,9 @@ static void linphone_iphone_message_received_unable_decrypt(LinphoneCore *lc, Li LinphoneChatMessage *message) { NSString *msgId = [NSString stringWithUTF8String:linphone_chat_message_get_custom_header(message, "Call-ID")]; + int index = [(NSNumber *)[LinphoneManager.instance.pushDict objectForKey:msgId] intValue] - 1; + LOGI(@"Decrementing index of long running task for call id : %@ with index : %d", msgId, index); [LinphoneManager.instance.pushDict setValue:[NSNumber numberWithInt:index] forKey:msgId]; BOOL need_bg_task = FALSE; for (NSString *key in [LinphoneManager.instance.pushDict allKeys]) { diff --git a/Resources/linphonerc-factory b/Resources/linphonerc-factory index d19b01d10..ff3807dcd 100644 --- a/Resources/linphonerc-factory +++ b/Resources/linphonerc-factory @@ -25,6 +25,7 @@ username_length=-1 sip_random_port=0 #whether SIP passwords must be encrypted in configuration storage file store_ha1_passwd=0 +deliver_imdn=1 [misc] #by default it is set to 30 by liblinphone