Identify a TWS Device
Read the device's TWS identity from the current SDK snapshot.
Prerequisites
- You have a
DeviceConvertibleinstance. - The device conforms to
DeviceTWSAPI.
API Reference
Framework
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>Protocol
- 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;
@endProperties
| Property | Type | Description |
|---|---|---|
isTws | Bool / BOOL | Whether the device identifies itself as a TWS device. |
Usage Examples
- 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");
}Error Handling
This property has no completion handler. Handle unsupported protocol conformance separately from a valid false value.
Best Practices
- Do Not Collapse Unsupported and False: Missing protocol conformance is not the same as
isTws == false. - Use Connection State Separately: Read
isTwsConnectedonly when connection state is relevant.
Notes
- This API is a synchronous property read, not a
getTWSSupportrequest. - It does not manage TWS pairing.