'How to check to which Bluetooth device my iPhone is connected
I have two options to establish a Bluetooth connection with my iPhone.
- Audio
- Calls
When I'm connected to the audio channel I can get the name of the device I'm connected to using AVAudioChannel as such:
let connectedAvSession = AVAudioSession.sharedInstance().currentRoute
let outputs = connectedAvSession.outputs
print("OnBoardingCarSelectionViewController, createArray() =>\n currently connected devices via audio session = ", outputs)
for output in outputs {
let name = output.portName.description
let uid = output.uid.description
let port = output.portType.rawValue
presentAlert("AV Channel", message: "name: \(name), uid: \(uid), port: \(port)")
}
When I change the connection to calls, I can't get the name of the device anymore. Is there a way I can know what I'm connected to when the connection is only set for phone calls?
Solution 1:[1]
An EAAccessoryManager object coordinates the attached accessories for an iOS-based device. Use the shared accessory manager to retrieve a list of connected accessories, and start and stop the delivery of connection and disconnection notifications.
Important :- Blockquote Phone and iPad apps running on Macs with Apple silicon never receive connection notifications.
below will be used for getting the connected Device:-
var connectedAccessories: [EAAccessory]
The accessory objects correspond to the list of currently connected accessories.
link for your reference:- https://developer.apple.com/documentation/externalaccessory/eaaccessorymanager/1613821-connectedaccessories
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

