-
Notifications
You must be signed in to change notification settings - Fork 0
Core Tws Get Connection Status
Mr.P edited this page Aug 25, 2026
·
2 revisions
Read whether the TWS device is currently connected.
- The device conforms to
DeviceTWSAPI. - Use
isTwswhen the UI must distinguish device type from connection state.
AIBuds.xcframework
import AIBuds#import <AIBuds/AIBuds.h>
#import <AIBuds/AIBuds-Swift.h>The connection state is exposed by DeviceTWSAPI.
/// The protocol for device True Wireless Stereo (TWS) related API.
protocol DeviceTWSAPI: DeviceAPI {
/// Indicates whether the TWS device is currently connected.
var isTwsConnected: Bool { get }
}/// The protocol for device True Wireless Stereo (TWS) related API.
@protocol AIBudsDeviceTWSAPI <AIBudsDeviceAPI>
/// Indicates whether the TWS device is currently connected.
@property (nonatomic, readonly) BOOL isTwsConnected;
@end| Property | Type | Description |
|---|---|---|
isTwsConnected |
Bool / BOOL
|
The current TWS connection snapshot. |
import AIBuds
guard let device = device as? DeviceTWSAPI else {
print("TWS information is unavailable")
return
}
guard device.isTws else {
print("This is not a TWS device")
return
}
print(device.isTwsConnected ? "TWS connected" : "TWS disconnected")id<AIBudsDeviceTWSAPI> device = (id<AIBudsDeviceTWSAPI>)self.device;
if ([device conformsToProtocol:@protocol(AIBudsDeviceTWSAPI)] && device.isTws) {
NSLog(@"%@", device.isTwsConnected ? @"TWS connected" : @"TWS disconnected");
}This property does not return an error. Treat it as a point-in-time snapshot and handle unsupported protocol conformance independently.
-
Observe Changes: Implement
didTwsConnectionStatusChangedfor a live indicator. - Avoid Connection Commands: This protocol does not initiate pairing or reconnection.
- Update UI Safely: Dispatch delegate-driven UI work to the main queue when required.
-
falsemeans the current TWS connection is not active; it does not by itself mean the device is not a TWS device. - The SDK Demo displays this property directly and updates it through the device delegate.
AIBuds SDK documentation · Full documentation · API Reference
- Introduction
- Getting Started
- Core Concepts
-
Core Features
- Basic Features
- Device Info
- Find Device
- Physical Operations
- Work Mode
- Work Status
- Wear Detection
- Volume Control
- Music Control
- TWS
- Equalizer
- ANC
- Audio
- Camera
- Remote Camera
- File Import
- Teleprompter
- Segment Navigation
- Live Streaming
- Device Applications
- OTA
- Camera OTA
- Service Auth
- AI Services
- Voice Assistant
- Logging
- Advanced Topics
- Releases
- Troubleshooting