简体   繁体   中英

CallKit Handling multiple calls(VOIP and GSM) issue in iOS

I have integrated CallKit in my VOIP app. I have made a VOIP call and the other end answered my call. Later I have received GSM call when the VOIP call is active. I have accepted GSM call by releasing audio and my VOIP app went to the background. After few seconds I have disconnected the GSM call but then I am getting delegate callback to below method:

- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action

In this method, I am actually disconnecting all my incoming/outgoing calls, so at the same time, both GSM and my VOIP calls got disconnected.

I am not sure why above delegate method getting called when I disconnect the GSM call if I am right... this method should be called only when I disconnect the VOIP call.

My roadmap is: After disconnecting GSM call I will start my audio service and will resume the VOIP call. But I am not able to proceed further since my VOIP call also getting disconnected.

The correct way (according to the sample code provided by Apple) to integrate with CallKit is that, all the actions you make should be done by using CXCallController to call requestTransaction:completion: method, and wait for CXProviderDelegate to trigger corresponding delegate method, and do the actual work there.

For example, if you want to hold the call, what you need to do is

CXSetHeldCallAction *setHeldCallAction = [[CXSetHeldCallAction alloc] initWithCallUUID:UUID onHold:onHold];
CXTransaction *transaction = [[CXTransaction alloc] initWithAction:setHeldCallAction];
[self.callController requestTransaction:transaction completion:^(NSError * _Nullable error) {
    if (error) {
        NSLog(@"%@", error);
    }
}];

Then the CXProviderDelegate will trigger provider:performSetHeldCallAction: , and you perform your handling inside that.

I am not sure why above delegate method getting called when I disconnect the GSM call if I am right... this method should be called only when I disconnect the VOIP call

There's no mention in the documentation that this method will be called only for calls made by your app. I assume this is right behavior and you need to get the call UUID to identify the call as one of yours else ignore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM