-fix issue with « ghost » long running task.

-Remove user notification of missed called on call push notification as no relevant information can be displayed.
This commit is contained in:
Jehan Monnier 2019-04-10 09:09:20 +02:00
parent 62d80ce36c
commit 721f724a74
2 changed files with 7 additions and 25 deletions

View file

@ -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.

View file

@ -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]]);