4

一旦我的 voip 呼叫被源或目的地断开,我正在尝试删除 callkit 屏幕。

我用了这段代码

CXEndCallAction *endaction = [[CXEndCallAction alloc] initWithCallUUID:[NSUUID UUID]];
CXCallController *callController = [[CXCallController alloc] initWithQueue:dispatch_get_main_queue()];
requestTransaction:[CXTransaction transactionWithActions:nil completion:completion]];

但是关闭 callkit 不起作用。谁能帮我解决这个问题?

4

2 回答 2

2

您可以在呼叫断开连接的方法上使用以下方法。

@property (nonatomic, strong) CXCallController *callKitCallController;

- (void)performEndCallActionWithUUID:(NSUUID *)uuid {
    if (uuid == nil) {
        return;
    }

    CXEndCallAction *endCallAction = [[CXEndCallAction alloc] initWithCallUUID:uuid];
    CXTransaction *transaction = [[CXTransaction alloc] initWithAction:endCallAction];

    [self.callKitCallController requestTransaction:transaction completion:^(NSError *error) {
        if (error) {
            NSLog(@"EndCallAction transaction request failed: %@", [error localizedDescription]);
        }
        else {
            NSLog(@"EndCallAction transaction request successful");
        }
    }];
}
于 2017-07-27T04:25:57.580 回答
0

你必须将你的CXTransactionwith传递给CXEndCallAction你的requestTransaction.

首先,initWithCallUUID您必须通过您当前的通话NSUUID。然后你可以调用requestTransaction你的CXCallController并传入[CXTransaction transactionWithActions:@[endaction]它,而不是nil像你一样。

CXEndCallAction *endaction = [[CXEndCallAction alloc] initWithCallUUID:[NSUUID UUID]]; // your current call UUID
CXCallController *callController = [[CXCallController alloc] initWithQueue:dispatch_get_main_queue()];
[callController requestTransaction:[CXTransaction transactionWithActions:@[endaction]] completion:completion];
于 2017-07-26T11:21:47.313 回答