首页 > 解决方案 > 如何在 iOS 应用程序中获取蓝牙配置文件状态

问题描述

当 iOS 设备与远程蓝牙设备连接时,我想在我的应用程序中获取蓝牙配置文件,即 ACL、耳机等状态。我找不到与它相关的任何东西。

谁能帮我实现这一目标?

标签: iosaudiobluetooth

解决方案


我认为您正在搜索的是 MPVolumeView。检查它 - https://developer.apple.com/documentation/mediaplayer/mpvolumeview

更新- 您可以观察音频路由更改 AVAudioSessionRouteChangeNotification

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioRouteChanged:) name:AVAudioSessionRouteChangeNotification object:nil];

您还可以从以下位置获取音频路由 -

for( AVAudioSessionPortDescription *portDescription in route.outputs )
{
    headphonesLocated |= ( [portDescription.portType 
  isEqualToString:AVAudioSessionPortHeadphones] );
}

推荐阅读