self.provider?.reportNewIncomingCall(with: self.callUUID!, update: update, completion: { (error) in
if error != nil {
}
if isIncoming { // incoming call
if !self.shouldReceiveCall {
let transaction = CXTransaction(action: CXEndCallAction(call: self.callUUID!))
self.callController?.request(transaction, completion: { error in })
return
}
let appDelegate = UIApplication.shared.delegate as! AppDelegate
if (appDelegate.window?.visibleViewController() as? SplashViewController) != nil {
self.isSplashLoading = true
return
}
self.isSplashLoading = false
self.isIncomingCall = true
self.expireTimer = Timer.scheduledTimer(timeInterval: kExpireCallCheck,
target: self,
selector: #selector(self.checkExpireCall),
userInfo: nil,
repeats: false)
}
else { // call rejected
self.provider?.reportCall(with: self.callUUID!, endedAt: nil, reason: .unanswered)
DispatchQueue.main.async {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
if let vc = appDelegate.window?.visibleViewController() as? CallScreenViewController {
vc.endCall()
}
}
}
})
Line 21 through 26 Is the Timer.
kExpireCallCheck (timer) is set for 60 seconds.
Basically, once the app is woken up and is in the process of receiving an incoming VoIP call, we want to fire up the timer so that after 60 seconds we can reject the call. We're can't get the timer to fire up.