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

8.3k views Asked by At

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.

3

There are 3 answers

1
Mohamed Adly On BEST ANSWER

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

19
AudioBubble On

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();
}
0
YSR fan On

Maintain only one instance of Provider, Configuration and CXCallController solved the end call issue.