You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native iOS端WebRTC默认使用内置麦克风而非蓝牙麦克风的解决求助

React Native iOS端WebRTC默认使用内置麦克风而非蓝牙麦克风的解决求助

我在自己的React Native项目里同时集成了react-native-incall-manager和react-native-webrtc,本来是想让音频能路由到蓝牙麦克风的——Android那边测试完全没问题,但iOS端死活就是用手机内置麦克风,连不上我已经配对好的蓝牙设备。

我不死心,自己写了个原生模块来手动配置AVAudioSession,代码如下:

#import "AudioSessionManager.h"
#import <AVFoundation/AVFoundation.h>

@implementation AudioSessionManager

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(configureAudioSession:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
  @try {
    AVAudioSession *session = [AVAudioSession sharedInstance];
    // Set category
    [session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];
    // Set mode
    [session setMode:AVAudioSessionModeVoiceChat error:nil];
    // Activate session
    [session setActive:YES error:nil];
    resolve(@(YES));
  } @catch (NSException *exception) {
    reject(@"session_config_error", @"Failed to configure AVAudioSession", nil);
  }
}

@end

结果运行之后还是没效果,iOS还是默认切回内置麦克风。有没有碰到过相同问题的老哥,或者懂iOS音频配置的大佬给指条路?

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.07 13:04:30