पहनने की पहचान की क्षमता देखें
पढ़ें कि डिवाइस पहनने की पहचान का समर्थन करता है या नहीं, और इस सुविधा को configure किया जा सकता है या नहीं।
आवश्यकताएँ
- डिवाइस कनेक्टेड और ready है।
- डिवाइस
DeviceWearDetectionAPIके अनुरूप है।
API संदर्भ
Framework
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>प्रोटोकॉल
यह capability DeviceWearDetectionAPI की property है।
- 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गुण
| Property | Type | विवरण |
|---|---|---|
wearDetectionCapability | WearDetectionCapability | डिवाइस द्वारा बताई गई मौजूदा capability। |
समर्थित मान
| Swift | Objective-C | अर्थ |
|---|---|---|
.none | AIBudsWearDetectionCapabilityNone | समर्थित नहीं। |
.supportedNotConfigurable | AIBudsWearDetectionCapabilitySupportedNotConfigurable | समर्थित है, लेकिन configurable नहीं। |
.supportedAndConfigurable | AIBudsWearDetectionCapabilitySupportedAndConfigurable | समर्थित और configurable है। |
उपयोग के उदाहरण
- 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;
}त्रुटि प्रबंधन
इस property का completion handler नहीं है। Protocol conformance विफल होने और भविष्य के अज्ञात enum values को संभालें। .none को transport error न मानें; यह valid capability value है।
श्रेष्ठ अभ्यास
- Configure करने से पहले पढ़ें: Enable/disable control दिखाने से पहले capability जाँचें।
- सभी Capability Levels अलग रखें: “configurable नहीं” को “समर्थित नहीं” में न मिलाएँ।
- भविष्य के मान संभालें: Swift में enum पर switch करते समय
@unknown defaultउपयोग करें।
नोट्स
- यह synchronous property read है, asynchronous
getWearDetectionSupportmethod नहीं। - SDK Demo इसी property से तय करता है कि configuration controls उपलब्ध हों या नहीं।