Twilio client voice call speaker ON/OFF issue

倖福魔咒の 提交于 2019-12-08 01:57:24

问题


I am using Twilio client voice call service for calling.

Here I am facing issue in spearke ON/OFF feature.I am able to Mute/Unmute call but not able to turn On/OFF speaker. I have a same instance for both functionality. I have also checked their demo project basic phone in that this speaker ON/OFF is working and I am doing same thing in my project bur not able to do the same.

Here is my code:

if(isSpeaker == NO)
{
     isSpeaker=YES;
     [self.phone setSpeakerEnabled:YES];
}
else{
     isSpeaker=NO;
     [self.phone setSpeakerEnabled:NO];
}

self.phone is the sharedInstance of BasicPhone (their call manager class) and I am testing application in > iOS 9 both demo and my project.


回答1:


I've used this code on iOS to successfully enable/disable speakerphone. It doesn't use the Twilio device, and is somewhat specific to React Native, but the core of each function should work:

RCT_EXPORT_METHOD(setSpeakerPhoneOn) {
AVAudioSession *session = [AVAudioSession sharedInstance];
NSError *error;

[session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&error];
}

RCT_EXPORT_METHOD(setSpeakerPhoneOff) {
AVAudioSession *session = [AVAudioSession sharedInstance];
NSError *error;

[session overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:&error];
}


来源:https://stackoverflow.com/questions/37893672/twilio-client-voice-call-speaker-on-off-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!