나는 블루투스 연결 쌍을 포함하는 응용 프로그램을 만들고 있습니다. 그래서 블루투스가 다른 장치 또는 액세서리에 연결되어 있는지 알고 싶습니까?iPhone의 Bluetooth가 다른 장치/액세서리에 연결되어 있는지 여부를 어떻게 확인할 수 있습니까?
iPhone에서 블루투스가 페어링되어 있는지 확인하십시오.
나는 블루투스 연결 쌍을 포함하는 응용 프로그램을 만들고 있습니다. 그래서 블루투스가 다른 장치 또는 액세서리에 연결되어 있는지 알고 싶습니까?iPhone의 Bluetooth가 다른 장치/액세서리에 연결되어 있는지 여부를 어떻게 확인할 수 있습니까?
iPhone에서 블루투스가 페어링되어 있는지 확인하십시오.
CBCentralManager
을 사용하여 연결된 블루투스 장치를 장치로 검색 할 수 있습니다. 당신의 블루투스 장치 (CBCentralManager
상태 == CBCentralManagerStatePoweredOn
)에있는 경우,이 함수를 호출 :
func retrieveConnectedPeripherals(withServices serviceUUIDs: [CBUUID]) -> [CBPeripheral]
그것은 당신의 아이폰에 연결된 모든 서비스의 UUID 당신의 목록을 제공합니다.
콜이 메소드는 블루투스 헤드셋이 연결되지 않았거나 찾을 수 있습니다.
먼저 수입 #import <AVFoundation/AVFoundation.h>
- (BOOL) isBluetoothHeadsetConnected
{
AVAudioSession *session = [AVAudioSession sharedInstance];
AVAudioSessionRouteDescription *routeDescription = [session currentRoute];
NSLog(@"Current Routes : %@", routeDescription);
if (routeDescription)
{
NSArray *outputs = [routeDescription outputs];
if (outputs && [outputs count] > 0)
{
AVAudioSessionPortDescription *portDescription = [outputs objectAtIndex:0];
NSString *portType = [portDescription portType];
NSLog(@"dataSourceName : %@", portType);
if (portType && [portType isEqualToString:@"BluetoothA2DPOutput"])
{
return YES;
}
}
}
return NO;
}
확인이 프레임 워크, 나는 그것을 시도 할 것이다. 감사 –