I have a need to check if the searched device is an AirPods device. I don’t know how to start. I hope to get your help. Thank you very much!
AVAudioSessionRouteDescription *currentRount = [AVAudioSession sharedInstance].currentRoute;
AVAudioSessionPortDescription *outputPort = currentRount.outputs[0];
if ([outputPort.portType isEqualToString:AVAudioSessionPortBluetoothA2DP]) {
} else {
}
I have not much of experience with audio framework of iOS, especially with Bluetooth module. But I did some reading. You could start with this:
How can I detect whether a HFP or A2DP is connected in iOS?
And the list of BT protocols (good read):
http://monkeycanz.com/hrf_faq/what-are-bluetooth-a2dp-avrcp-hfp-hsp-protocols/
And then to answer your question, here's the documentation of Apple for
AVAudioSessionPort
https://developer.apple.com/documentation/avfoundation/avaudiosessionport?language=objc
From there you can see the constants for that structure, such as:
AVAudioSessionPortHeadphones
- Output to wired headphones.AVAudioSessionPortHeadsetMic
- A wired headset’s built-in microphone.So there. Imo, if you have these kinds of constants (and please check the other constants too), you have what you're looking for.
Hope it helps!