-->

Callkit doesn't recognize connected info of ou

2019-07-15 01:17发布

问题:

I'm adding callkit framework to my Obj-C VoIP app. But there are some problems with making outgoing call. Callkit doesn't recognize connected info of outgoing call.

Detail

  1. My App reported connected info by using [provider reportOutgoingCallWithUUID:uuid connectedAtDate:nil];, but Callkit doesn't receive that.
  2. The first time of making outgoing call, connected info has reported and callkit system's native screen shows time info correctly (connected).
  3. But after two times or more, it hasn't reported not at all.
  4. Of course I've set Delegate method.
  5. Connecting info is always reported correctly by using [provider reportOutgoingCallWithUUID:uuid startedConnectingAtDate:nil];.

Is there any advice or information?

回答1:

/You need to call connecting and connected state change after audio session is activated. You can do it by using block. Create block at sip call model and assign block executing code after audio session enabled. Call this block on sip call state event./

/*Configure the audio session, but do not start call audio here, since it must be done once the audio session has been activated by the system after having its priority elevated. */

- (void)provider:(CXProvider *)provider performStartCallAction:(CXStartCallAction *)action {

  _outgoingCallId = action.callUUID;
  _outgoingCallHandler = action.handle.value;
  _destinationURI = action.contactIdentifier;

  [[AudioManager sharedManager] configureAudioSession];

  [action fulfill];
}

/* Set callback blocks for significant events in the call's lifecycle, so that the CXProvider may be updated to reflect the updated state.*/

 - (void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession *)audioSession {

     SIPCall *call = [[[SIPUserAgent sharedUserAgent] account]makeCallToURI:_destinationURI];
    call.connectingBlock = ^{
        NSLog(@"----- connecting block -----");
        [_provider reportOutgoingCallWithUUID:_outgoingCallId startedConnectingAtDate:nil];
    };

    call.connectedBlock = ^{
        NSLog(@"----- connected block -----");
        [_provider reportOutgoingCallWithUUID:_outgoingCallId connectedAtDate:nil];
    };

}

//Call Block from sip call event

- (void)SIPCallConnecting:(NSNotification *)notification {

   SIPCall *call = [notification object];
   if (call.connectingBlock) {
        call.connectingBlock();
   }
}

- (void)SIPCallDidConfirm:(NSNotification *)notification {
      SIPCall *call = [notification object];
      [self setCallStartTime:[NSDate timeIntervalSinceReferenceDate]];
      [actv startCallTimer];
      if (call.connectedBlock) {
         call.connectedBlock();
    }
}