remove useless code

This commit is contained in:
Danmei Chen 2020-03-24 09:17:08 +01:00
parent 10390bd67a
commit b0e83b970a
3 changed files with 5 additions and 73 deletions

View file

@ -43,7 +43,6 @@ import AVFoundation
@objc var speakerEnabled : Bool = false
@objc var bluetoothEnabled : Bool = false
@objc var nextCallIsTransfer: Bool = false
@objc var callHandled: String = ""
fileprivate override init() {
@ -182,15 +181,6 @@ import AVFoundation
}
}
// There is an error before display an incoming call. Attention, it's unnormal in this case!
@objc func displayForkIncomingCall() {
if CallManager.incomingCallMustBeDisplayed() {
// Display the call in any way, otherwise it will cause a crash.
Log.directLog(BCTBX_LOG_ERROR, text: "CallKit: please check the pushkit notification, there must be something wrong!")
providerDelegate.reportForkIncomingCall();
}
}
func displayIncomingCall(call:Call?, handle: String, hasVideo: Bool, callId: String) {
let uuid = UUID()
let callInfo = CallInfo.newIncomingCallInfo(callId: callId)

View file

@ -58,7 +58,6 @@
- (void)applicationDidEnterBackground:(UIApplication *)application {
LOGI(@"%@", NSStringFromSelector(_cmd));
[LinphoneManager.instance enterBackgroundMode];
CallManager.instance.callHandled = @"";
LinphoneCall *call = linphone_core_get_current_call(LC);
if (!call) {
@ -426,47 +425,16 @@
}
}
-(void)displayfailedcall {
}
- (void)processRemoteNotification:(NSDictionary *)userInfo {
// TODO: it works only for calls.
// support only for calls
NSDictionary *aps = [userInfo objectForKey:@"aps"];
if (!aps) {
LOGE(@"Notification [%p] was empy, it's impossible to process it.", userInfo);
[CallManager.instance displayForkIncomingCall];
return;
}
NSString *loc_key = [aps objectForKey:@"loc-key"] ?: [[aps objectForKey:@"alert"] objectForKey:@"loc-key"];
if (!loc_key) {
LOGE(@"Notification [%p] has no loc_key, it's impossible to process it.", userInfo);
[CallManager.instance displayForkIncomingCall];
return;
}
//NSString *loc_key = [aps objectForKey:@"loc-key"] ?: [[aps objectForKey:@"alert"] objectForKey:@"loc-key"];
NSString *callId = [aps objectForKey:@"call-id"] ?: @"";
if ([callId isEqualToString:@""]) {
[CallManager.instance displayForkIncomingCall];
}
if (![loc_key isEqualToString:@"IC_MSG"]) {
[CallManager.instance displayForkIncomingCall];
}
if([CallManager incomingCallMustBeDisplayed]) {
if([CallManager callKitEnabled]) {
// Since ios13, a new Incoming call must be displayed when the callkit is enabled and app is in background.
// Otherwise it will cause a crash.
if ([CallManager.instance.callHandled isEqualToString:callId]) {
LOGD(@"Notification has traited (Background).");
} else {
CallManager.instance.callHandled = callId;
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive && [self addLongTaskIDforCallID:callId]) {
[LinphoneManager.instance startPushLongRunningTask:loc_key callId:callId];
}
[LinphoneManager.instance addPushCallId:callId];
[CallManager.instance displayIncomingCallWithCallId:callId];
}
[CallManager.instance displayIncomingCallWithCallId:callId];
} else {
if (linphone_core_get_calls(LC)) {
// if there are calls, obviously our TCP socket shall be working
@ -474,20 +442,6 @@
return;
}
if ([CallManager.instance.callHandled isEqualToString:callId]) {
LOGD(@"Notification has traited (Foreground).");
return;
}
NSString *uuid = [NSString stringWithFormat:@"<urn:uuid:%@>", [LinphoneManager.instance lpConfigStringForKey:@"uuid" inSection:@"misc" withDefault:NULL]];
NSString *sipInstance = [aps objectForKey:@"uuid"];
if (sipInstance && uuid && ![sipInstance isEqualToString:uuid]) {
LOGE(@"Notification [%p] was intended for another device, ignoring it.", userInfo);
LOGD(@"My sip instance is: [%@], push was intended for: [%@].", uuid, sipInstance);
return;
}
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive && [self addLongTaskIDforCallID:callId])
[LinphoneManager.instance startPushLongRunningTask:loc_key callId:callId];
if ([callId isEqualToString:@""]) {
// Present apn pusher notifications for info
LOGD(@"Notification [%p] came from flexisip-pusher.", userInfo);
@ -504,19 +458,7 @@
LOGD(error.description);
}
}];
} else {
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.repeatInterval = 0;
notification.alertBody = @"Push notification received !";
notification.alertTitle = @"APN Pusher";
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
}
} else if (![callId isEqualToString:@""] && [loc_key isEqualToString:@"IC_MSG"] && [CallManager callKitEnabled]) {
// Report a new Incoming call when app is in foreground.
if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive && [self addLongTaskIDforCallID:callId]) {
[LinphoneManager.instance startPushLongRunningTask:loc_key callId:callId];
}
[LinphoneManager.instance addPushCallId:callId];
}
}

View file

@ -133,6 +133,7 @@ class ProviderDelegate: NSObject {
// MARK: - CXProviderDelegate
extension ProviderDelegate: CXProviderDelegate {
func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
action.fulfill()
let uuid = action.callUUID
let callId = callInfos[uuid]?.callId
@ -147,7 +148,6 @@ extension ProviderDelegate: CXProviderDelegate {
CallManager.instance().terminateCall(call: call.getCobject);
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: Call ended with call-id: \(String(describing: callId)) an UUID: \(uuid.description).")
}
action.fulfill()
}
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {