From 721f724a745cdf8a8bc35b66871004f0cf026fb9 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 10 Apr 2019 09:09:20 +0200 Subject: [PATCH] =?UTF-8?q?-fix=20issue=20with=20=C2=AB=C2=A0ghost=C2=A0?= =?UTF-8?q?=C2=BB=20long=20running=20task.=20-Remove=20user=20notification?= =?UTF-8?q?=20of=20missed=20called=20on=20call=20push=20notification=20as?= =?UTF-8?q?=20no=20relevant=20information=20can=20be=20displayed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/LinphoneAppDelegate.m | 2 +- Classes/LinphoneManager.m | 30 ++++++------------------------ 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 2940b9515..62f113a64 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -441,7 +441,7 @@ } NSString *callId = [aps objectForKey:@"call-id"] ?: @""; - if ([self addLongTaskIDforCallID:callId] && [UIApplication sharedApplication].applicationState != UIApplicationStateActive) + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive && [self addLongTaskIDforCallID:callId]) [LinphoneManager.instance startPushLongRunningTask:loc_key callId:callId]; // if we receive a push notification, it is probably because our TCP background socket was no more working. diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 01f267f68..6fcf226bf 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -2300,30 +2300,12 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { [[UIApplication sharedApplication] endBackgroundTask:pushBgTaskCall]; pushBgTaskCall = 0; pushBgTaskCall = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ - if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { - LOGW(@"Incomming call with call-id [%@] couldn't be received", callId); - UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; - content.title = NSLocalizedString(@"Missed call", nil); - content.body = NSLocalizedString(@"You have missed a call.", nil); - content.categoryIdentifier = @"push_call"; - - UNNotificationRequest *req = - [UNNotificationRequest requestWithIdentifier:@"push_call" content:content trigger:NULL]; - [[UNUserNotificationCenter currentNotificationCenter] - addNotificationRequest:req - withCompletionHandler:^(NSError *_Nullable error) { - // Enable or disable features based on authorization. - if (error) { - LOGD(@"Error while adding notification request :"); - LOGD(error.description); - } - }]; - } - for (NSString *key in [LinphoneManager.instance.pushDict allKeys]) { - [LinphoneManager.instance.pushDict setValue:[NSNumber numberWithInt:0] forKey:key]; - } - [[UIApplication sharedApplication] endBackgroundTask:pushBgTaskCall]; - pushBgTaskCall = 0; + //does not make sens to notify user as we have no information on this missed called + for (NSString *key in [LinphoneManager.instance.pushDict allKeys]) { + [LinphoneManager.instance.pushDict setValue:[NSNumber numberWithInt:0] forKey:key]; + } + [[UIApplication sharedApplication] endBackgroundTask:pushBgTaskCall]; + pushBgTaskCall = 0; }]; LOGI(@"Call long running task started for call-id [%@], remaining [%@] because a push has been received", callId, [LinphoneUtils intervalToString:[[UIApplication sharedApplication] backgroundTimeRemaining]]);