Hi ,
I have a problem with observing call status in iPadOS 14.
callObserver:callChanged:
method not invoked when I initiate a cellular call from iPad ( using url as tel://). But same code working fine in iPhone - iOS 14.
My Code ,
import UIKit
import CallKit
class ViewController: UIViewController, CXCallObserverDelegate {
private lazy var callObserver = CXCallObserver()
override func viewDidLoad() {
super.viewDidLoad()
configureCallButton()
view.backgroundColor = .gray
self.callObserver.setDelegate(self, queue: nil)
// Do any additional setup after loading the view.
}
func configureCallButton() {
let button = UIButton(type: .system)
button.setTitle("Call", for: .normal)
let attStr = NSMutableAttributedString(string: "Call", attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 25), NSAttributedString.Key.foregroundColor: UIColor.blue]);
button.setAttributedTitle(attStr, for: .normal)
button.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(button)
button.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
button.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
button.addTarget(self, action: #selector(initiateCall), for: .touchUpInside)
}
@objc func initiateCall() {
if let url = URL(string: "tel://*********") {
UIApplication.shared.openURL(url)
}
}
func callObserver(_ callObserver: CXCallObserver, callChanged call: CXCall) {
if call.isOutgoing {
print("Call outgoing")
}
else if call.hasConnected {
print("Call has connected")
}
else if call.hasEnded {
print("Call has ended")
}
}
}
Note: Observer method invoked for FaceTime calls in iPadOS 14.( using url as facetime:// )