I'm working on an app for a hands free BLE device for changing music and answering phone calls. Everything I'm reading says this can't be done, but figured I'd ask and see if maybe there was a change now with CallKit.
I'm able to see call events using CXCallObserverDelegate, but am unable to answer phone calls with the CXAnswerCallAction.
Here is my current code, I'm using a delay for testing purposes. Eventually the action would be triggered by an action from the BLE device:
self.currentCallUUID = call.uuid
if let callUUID = self.currentCallUUID
{
let answerAction: CXAnswerCallAction = CXAnswerCallAction(call: callUUID)
let transaction: CXTransaction = CXTransaction(action: answerAction)
let when = DispatchTime.now() + 2
DispatchQueue.main.asyncAfter(deadline: when) {
print("answering call")
self.callController.request(transaction, completion: { error in
if (error != nil)
{
print("did answer")
answerAction.fulfill()
}
else
{
print("answer failed: \(String(describing: error?.localizedDescription))")
}
})
}
}