fix not display IncomingCall when pushnotification is disabled

This commit is contained in:
Danmei Chen 2020-06-12 11:34:54 +02:00
parent 1b3bc34fca
commit 21fbc51405

View file

@ -392,6 +392,15 @@ import AVFoundation
class CoreManagerDelegate: CoreDelegate {
static var speaker_already_enabled : Bool = false
func getProxyConfigByIncomingCall(call:Call, lc:Core) ->ProxyConfig? {
let addr = call.toAddress
let proxylist = lc.proxyConfigList
if let index = proxylist.firstIndex(where: { $0.identityAddress?.asStringUriOnly() == addr?.asStringUriOnly() }) {
return proxylist[index]
}
return nil
}
override func onCallStateChanged(lc: Core, call: Call, cstate: Call.State, message: String) {
let addr = call.remoteAddress;
let address = FastAddressBook.displayName(for: addr?.getCobject) ?? "Unknow"
@ -423,8 +432,11 @@ class CoreManagerDelegate: CoreDelegate {
// The call is already answered.
CallManager.instance().acceptCall(call: call, hasVideo: video)
}
} else if (!(CallManager.instance().alreadyRegisteredForNotification && UIApplication.shared.isRegisteredForRemoteNotifications)) {
CallManager.instance().displayIncomingCall(call: call, handle: address, hasVideo: video, callId: callId!)
} else {
let cfg = getProxyConfigByIncomingCall(call: call, lc: lc)
if (!((cfg?.isPushNotificationAllowed ?? true) && CallManager.instance().alreadyRegisteredForNotification && UIApplication.shared.isRegisteredForRemoteNotifications)) {
CallManager.instance().displayIncomingCall(call: call, handle: address, hasVideo: video, callId: callId!)
}
}
} else if (UIApplication.shared.applicationState != .active) {
// not support callkit , use notif