2016-12-10 5 views
5

द्वारा वापस नहीं कहा जाता है, मैं अपने वीओआईपी ऐप के साथ नए कॉलकिट एपीआई को एकीकृत कर रहा हूं।didActivate को कॉलकिट

के रूप में उदाहरण के ऐप में दिखाए गए: https://developer.apple.com/library/content/samplecode/Speakerbox/Introduction/Intro.html

मैं ऑडियो सत्र को विन्यस्त कर रहा हूँ:

- (void) configureAudioSession 
{ 
    // Configure the audio session 
    AVAudioSession *sessionInstance = [AVAudioSession sharedInstance]; 

    // we are going to play and record so we pick that category 
    NSError *error = nil; 
    [sessionInstance setCategory:AVAudioSessionCategoryPlayAndRecord error:&error]; 
    if (error) { 
     NSLog(@"error setting audio category %@",error); 
    } 

    // set the mode to voice chat 
    [sessionInstance setMode:AVAudioSessionModeVoiceChat error:&error]; 
    if (error) { 
     NSLog(@"error setting audio mode %@",error); 
    } 

    NSLog(@"setupAudioSession"); 

    return; 
} 
मेरी CXAnswerCallAction में

:

func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) { 
     print("Provider - CXAnswerCallAction") 

     // get the active call 
     guard let call = self.softphone.getCallForCallId(self.currentCallId) else { 
      action.fail() 
      return 
     } 

     /* 
     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. 
     */ 
     self.softphone.configureAudioSession() 

     // Trigger the call to be answered via the underlying network service. 
     call.answer() 

     // Signal to the system that the action has been successfully performed. 
     action.fulfill() 
    } 

प्रलेखन के अनुसार, didActivate बुलाया जाना चाहिए कॉलकिट द्वारा वापस:

func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) { 
    print("Provider - Received \(#function)") 

    // Start call audio media, now that the audio session has been activated after having its priority boosted. 
} 

कुछ कारणों से, इसे पहले वीओआईपी कॉल के बाद वापस नहीं कहा जाता है। बाद की कॉल कॉलबैक प्राप्त करने लगती हैं और वे ठीक काम करते हैं।

इसे कैसे ठीक करें?

उत्तर

1

मैंने पहले कॉल ऑडियो सेट करके इस समस्या को ठीक कर दिया है और फिर "reportNewIncomingCall" विधि को कॉल करें। नमूना कोड नीचे दिया गया है:

func reportIncomingCall(uuid: UUID, handle: String, hasVideo: Bool = false, completion: ((NSError?) -> Void)? = nil) { 
    let update = CXCallUpdate() 
    update.remoteHandle = CXHandle(type: .phoneNumber, value: handle) 
    update.hasVideo = hasVideo 


    DispatchQueue.global().sync { 
     _ = try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.mixWithOthers) 
     _ = try? AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSessionPortOverride.none) 
     if hasVideo == true { 
      _ = try? AVAudioSession.sharedInstance().setMode(AVAudioSessionModeVideoChat) 
     } else { 
      _ = try? AVAudioSession.sharedInstance().setMode(AVAudioSessionModeVoiceChat) 
     } 


     do { 
      _ = try AVAudioSession.sharedInstance().setActive(true) 
     } catch (let error){ 
      print("audio session error: \(error)") 
     } 
    } 

    provider.reportNewIncomingCall(with: uuid, update: update) { error in 

     if error == nil { 

     } 

     completion?(error as? NSError) 
    } 
} 
संबंधित मुद्दे