0

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))")
                    }
                })
            }
        }
jscs
  • 63,694
  • 13
  • 151
  • 195
Christopher Larsen
  • 1,375
  • 15
  • 22
  • 1
    You can't do it with BLE. You need your device to use the legacy Bluetooth hands free profile – Paulw11 May 24 '17 at 22:47
  • Is there maybe a way to do this with SiriKit? I've never worked with sirikit, but figured I'd ask. EDIT: Looks like it's also only for VOIP. Oh well I tried, thanks @Paulw11 – Christopher Larsen May 25 '17 at 16:12

0 Answers0