问题
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