본문으로 건너뛰기

착용 감지 지원 수준 확인

기기의 착용 감지 지원 여부와 설정 가능 여부를 읽습니다.

사전 요구 사항

  • 기기가 연결되어 사용할 수 있는 상태입니다.
  • 기기가 DeviceWearDetectionAPI를 준수합니다.

API 참고

프레임워크

AIBuds.xcframework

가져오기

Swift
import AIBuds

프로토콜

지원 수준은 DeviceWearDetectionAPI의 속성으로 제공됩니다.

Swift
/// The protocol for device wear detection API.
protocol DeviceWearDetectionAPI: DeviceAPI {
    /// The wear-detection capabilities supported by the device
    var wearDetectionCapability: WearDetectionCapability { get }
}

속성

속성타입설명
wearDetectionCapabilityWearDetectionCapability기기가 현재 보고한 지원 수준입니다.

지원 값

SwiftObjective-C의미
.noneAIBudsWearDetectionCapabilityNone지원하지 않습니다.
.supportedNotConfigurableAIBudsWearDetectionCapabilitySupportedNotConfigurable지원하지만 설정할 수 없습니다.
.supportedAndConfigurableAIBudsWearDetectionCapabilitySupportedAndConfigurable지원하며 설정할 수 있습니다.

사용 예제

Swift
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")
}

오류 처리

이 속성에는 completion handler가 없습니다. 프로토콜 미지원과 향후 추가되는 알 수 없는 enum 값을 처리하세요. .none은 유효한 지원 수준 값이므로 전송 오류로 해석하지 마세요.

권장 사항

  1. 설정 전에 조회: 활성화 UI를 표시하기 전에 지원 수준을 확인하세요.
  2. 지원 수준 구분: ‘설정 불가’를 ‘미지원’으로 처리하지 마세요.
  3. 향후 값 처리: Swift에서 enum을 분기할 때 @unknown default를 사용하세요.

참고

  • 이 API는 동기식 속성 읽기이며 비동기 getWearDetectionSupport 메서드가 아닙니다.
  • SDK Demo는 이 속성을 사용하여 설정 UI 표시 여부를 결정합니다.