How to close Callkit screen after VOIP call disconnected

自作多情 提交于 2020-01-04 04:06:27

问题


I am trying to remove callkit screen once my voip call is disconnected by source or destination.

I used this code

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

But it is not working to close the callkit. Can any one help me to solve this issue?


回答1:


You can use this below method on call disconnected method.

@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");
        }
    }];
}



回答2:


You have to pass your CXTransaction with CXEndCallAction into your requestTransaction.

First of all in initWithCallUUID you have to pass your current call NSUUID. Then you can call requestTransaction on your CXCallController and pass [CXTransaction transactionWithActions:@[endaction] into it, instead of nil as you did.

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];


来源:https://stackoverflow.com/questions/45302120/how-to-close-callkit-screen-after-voip-call-disconnected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!