12

这不是一个给我代码的问题,这是一个可行性问题。如果我使用 CallKit 发起电话呼叫,是否也可以以编程方式结束它?

4

3 回答 3

12

是的,我们可以以编程方式进行,但我们必须保留该调用的 UUID,

CXEndCallAction *endaction = [[CXEndCallAction alloc] initWithCallUUID:callUUID];
[cxcallcontrollerobject requestTransaction:[CXTransaction transactionWithActions:@[action]] completion:completion];


    + (CXTransaction *)transactionWithActions:(NSArray <CXAction *> *)actions { 
        CXTransaction *transcation = [[CXTransaction alloc] init]; 
        for (CXAction *action in actions) { 
           [transcation addAction:action]; 
        } 
        return transcation; 
 }

希望这可以帮助。

于 2016-11-08T14:16:08.860 回答
5

关闭所有通话 (Swift4)

func endCall(call: UUID) {

    let endCallAction = CXEndCallAction(call: call)
    let transaction = CXTransaction(action: endCallAction)
    cxCallController.request(transaction) { error in
        if let error = error {
            print("EndCallAction transaction request failed: \(error.localizedDescription).")
            self.cxCallProvider.reportCall(with: call, endedAt: Date(), reason: .remoteEnded)
            return
        }

        print("EndCallAction transaction request successful")

    }

}
于 2018-05-17T06:07:18.650 回答
4

快速使用以下代码,uuidCallKit 是我正在与我进行的当前呼叫的 UUID。

let controller = CXCallController()
let transaction = CXTransaction(action: 
CXEndCallAction(call: uuidCallKit))controller.request(transaction,completion: { error in })
于 2018-03-23T12:27:28.810 回答