新しい CallKit API を VOIP アプリに統合しています。
サンプルアプリに示すように: 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.
}
何らかの理由で、最初の VOIP コールの後、コールバックされません。後続の呼び出しはコールバックを受信しているようで、正常に動作します。
これを修正する方法は?