TWS डिवाइस की पहचान करें
वर्तमान SDK snapshot से डिवाइस की TWS पहचान पढ़ें।
आवश्यक शर्तें
- आपके पास
DeviceConvertibleinstance है। - डिवाइस
DeviceTWSAPIको conform करता है।
API संदर्भ
Framework
AIBuds.xcframework
Import
- 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प्रॉपर्टी
| Property | Type | विवरण |
|---|---|---|
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");
}त्रुटि प्रबंधन
इस property का completion handler नहीं है। Unsupported protocol conformance को valid false value से अलग संभालें।
श्रेष्ठ अभ्यास
- Unsupported और False को एक न मानें: Protocol conformance न होना
isTws == falseके समान नहीं है। - Connection state अलग रखें: Connection state की जरूरत होने पर ही
isTwsConnectedपढ़ें।
ध्यान दें
- यह API synchronous property read है,
getTWSSupportrequest नहीं। - यह TWS pairing manage नहीं करता।