简体   繁体   中英

Callkit call End issue(error domain=com.apple.callkit.error.requesttransaction code=4) and Audio issue after Call accept

I made VOIP App.For that i am using PushKit and Callkit with pjsip.

When app in background get notification of call and based on this i open callkit screen and after click on accept call connect using pjsip.

1) call End issue

but when call hangout pjsip call hangout successfully but then callkit give me following error:

error domain=com.apple.callkit.error.requesttransaction code=4

For that i checked answer and end call uuid also same but again not end call.I spent lot of time but not get any solution.

Any one have solution then please help me.

2) Audio issue After Accept call

After Accept call audio is not configure.Audio session give me following error :

audio session error: Error Domain=NSOSStatusErrorDomain Code=561017449 "(null)" [aurioc] 892: failed: '!pri' (enable 3, outf< 1 ch, 44100 Hz, Int16> inf< 1 ch, 44100 Hz, Int16>)

For above error any one have solution then give me.

Thank you.

1) call End issue

com.apple.callkit.error.requesttransaction code=4 is saying that UUID is unknown.

CXErrorCodeRequestTransactionErrorUnknownCallUUID = 4

To end call properly in CallKit framework you have to init CXEndCallAction with your unique UUID and request transaction with "end call action" from your CXCallController .

CXEndCallAction *action = [[CXEndCallAction alloc] initWithCallUUID:c_UUID]; 
[self.callController requestTransaction:[CXTransaction transactionWithActions:@[action]] completion:completion];

In the provider method you should end your call through pjsip and don't forget to call [action fulfill] .

- (void)provider:(CXProvider *)provider performEndCallAction:(nonnull CXEndCallAction *)action {
   // get your current pjsip call object
   ...
   // make hangup - something like:
   pj_status_t status = pjsua_call_hangup([self identifier], 0, NULL, NULL);
   if (status != PJ_SUCCESS) {
       NSString *errStr = [NSString stringWithFormat:@"Error hanging up call %@", self];
       ALog(@"%@", errStr);
   }
   [action fulfill];
}

2) Audio issue After Accept call

When you accept the call following method is triggered - (void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession *)audioSession and when you end the call this method is called (void)provider:(CXProvider *)provider didDeactivateAudioSession:(AVAudioSession *)audioSession .

- (void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession *)audioSession{
    // start audio and configure pjsip sound
    pj_status_t status = pjsua_set_snd_dev(input, output); // '0' for input and output
}

And deactivate sound for pjsip call in following method.

- (void)provider:(CXProvider *)provider didDeactivateAudioSession:(AVAudioSession *)audioSession{
    // end audio
    pj_status_t status = pjsua_set_null_snd_dev();
}

I fixed it by making the class which contains the CallKit functions as a singleton and never allocate a new instance of it. You can take a look at this helper class:

https://github.com/naandonov-mm/iOS-10-Sampler/tree/master/CallKit

只维护 Provider、Configuration 和 CXCallController 的一个实例就解决了结束调用问题。

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