TWS 기기 여부 확인
현재 SDK 스냅샷에서 기기의 TWS 여부를 읽습니다.
사전 요구 사항
DeviceConvertible인스턴스가 있습니다.- 기기가
DeviceTWSAPI를 준수합니다.
API 참고
프레임워크
AIBuds.xcframework
가져오기
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>프로토콜
- Swift
- Objective-C
/// The protocol for device True Wireless Stereo (TWS) related API.
protocol DeviceTWSAPI: DeviceAPI {
/// Indicates whether the device is a True Wireless Stereo (TWS) device.
var isTws: Bool { get }
}/// The protocol for device True Wireless Stereo (TWS) related API.
@protocol AIBudsDeviceTWSAPI <AIBudsDeviceAPI>
/// Indicates whether the device is a True Wireless Stereo (TWS) device.
@property(nonatomic, readonly) BOOL isTws;
@end속성
| 속성 | 타입 | 설명 |
|---|---|---|
isTws | Bool / BOOL | 기기가 TWS 기기로 식별되는지 여부입니다. |
사용 예제
- Swift
- Objective-C
import AIBuds
guard let device = device as? DeviceTWSAPI else {
print("TWS information is unavailable")
return
}
print(device.isTws ? "TWS device" : "Not a TWS device")id<AIBudsDeviceTWSAPI> device = (id<AIBudsDeviceTWSAPI>)self.device;
if ([device conformsToProtocol:@protocol(AIBudsDeviceTWSAPI)]) {
NSLog(@"%@", device.isTws ? @"TWS device" : @"Not a TWS device");
}오류 처리
이 속성에는 completion handler가 없습니다. 프로토콜 미지원과 유효한 false 값을 구분하여 처리하세요.
권장 사항
- 미지원과 false 구분: 프로토콜을 준수하지 않는 상태는
isTws == false와 다릅니다. - 연결 상태 별도 확인: 연결 상태가 필요한 경우에만
isTwsConnected를 읽으세요.
참고
- 이 API는 동기식 속성 읽기이며
getTWSSupport요청이 아닙니다. - TWS 페어링을 관리하지 않습니다.