착용 감지 지원 수준 확인
기기의 착용 감지 지원 여부와 설정 가능 여부를 읽습니다.
사전 요구 사항
- 기기가 연결되어 사용할 수 있는 상태입니다.
- 기기가
DeviceWearDetectionAPI를 준수합니다.
API 참고
프레임워크
AIBuds.xcframework
가져오기
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>프로토콜
지원 수준은 DeviceWearDetectionAPI의 속성으로 제공됩니다.
- Swift
- Objective-C
/// The protocol for device wear detection API.
protocol DeviceWearDetectionAPI: DeviceAPI {
/// The wear-detection capabilities supported by the device
var wearDetectionCapability: WearDetectionCapability { get }
}/// The protocol for device wear detection API.
@protocol AIBudsDeviceWearDetectionAPI <AIBudsDeviceAPI>
/// The wear-detection capabilities supported by the device
@property(nonatomic, readonly) enum AIBudsWearDetectionCapability wearDetectionCapability;
@end속성
| 속성 | 타입 | 설명 |
|---|---|---|
wearDetectionCapability | WearDetectionCapability | 기기가 현재 보고한 지원 수준입니다. |
지원 값
| Swift | Objective-C | 의미 |
|---|---|---|
.none | AIBudsWearDetectionCapabilityNone | 지원하지 않습니다. |
.supportedNotConfigurable | AIBudsWearDetectionCapabilitySupportedNotConfigurable | 지원하지만 설정할 수 없습니다. |
.supportedAndConfigurable | AIBudsWearDetectionCapabilitySupportedAndConfigurable | 지원하며 설정할 수 있습니다. |
사용 예제
- Swift
- Objective-C
import AIBuds
guard let device = device as? DeviceWearDetectionAPI else {
print("Wear detection is not exposed by this device")
return
}
switch device.wearDetectionCapability {
case .none:
print("Wear detection is not supported")
case .supportedNotConfigurable:
print("Wear detection is supported but not configurable")
case .supportedAndConfigurable:
print("Wear detection is supported and configurable")
@unknown default:
print("Unknown wear-detection capability")
}#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>
id<AIBudsDeviceWearDetectionAPI> device = (id<AIBudsDeviceWearDetectionAPI>)self.device;
if (![device conformsToProtocol:@protocol(AIBudsDeviceWearDetectionAPI)]) {
NSLog(@"Wear detection is not exposed by this device");
return;
}
switch (device.wearDetectionCapability) {
case AIBudsWearDetectionCapabilityNone:
NSLog(@"Wear detection is not supported");
break;
case AIBudsWearDetectionCapabilitySupportedNotConfigurable:
NSLog(@"Wear detection is supported but not configurable");
break;
case AIBudsWearDetectionCapabilitySupportedAndConfigurable:
NSLog(@"Wear detection is supported and configurable");
break;
}오류 처리
이 속성에는 completion handler가 없습니다. 프로토콜 미지원과 향후 추가되는 알 수 없는 enum 값을 처리하세요. .none은 유효한 지원 수준 값이므로 전송 오류로 해석하지 마세요.
권장 사항
- 설정 전에 조회: 활성화 UI를 표시하기 전에 지원 수준을 확인하세요.
- 지원 수준 구분: ‘설정 불가’를 ‘미지원’으로 처리하지 마세요.
- 향후 값 처리: Swift에서 enum을 분기할 때
@unknown default를 사용하세요.
참고
- 이 API는 동기식 속성 읽기이며 비동기
getWearDetectionSupport메서드가 아닙니다. - SDK Demo는 이 속성을 사용하여 설정 UI 표시 여부를 결정합니다.