Stop Find Device
Request that a connected device stop its firmware-defined locate-device indication.
Prerequisites
Before calling this API, ensure:
- The device is connected and ready
- The device supports the
DeviceFindAPIprotocol
API Reference
Framework
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>Protocol
The stopFindDevice method is defined in DeviceFindAPI.
- Swift
- Objective-C
/// Controls the locate-device indication on a connected device.
///
/// This API operates on the device represented by the conforming object. It
/// does not perform Bluetooth discovery or scan for nearby devices.
public protocol DeviceFindAPI: DeviceAPI {
/// Requests that the connected device stop its locate-device indication.
/// - Parameters:
/// - completion: Called when command processing completes.
/// - success: `true` when the device accepted the stop command;
/// otherwise, `false`.
/// - error: The command or communication error, or `nil` on success.
func stopFindDevice(_ completion: AIBudsCompletionHandler?)
}/// Controls the locate-device indication on a connected device.
@protocol AIBudsDeviceFindAPI <AIBudsDeviceAPI>
/// Requests that the connected device stop its locate-device indication.
/// - Parameters:
/// - completion: Called when command processing completes.
/// - success: `true` when the device accepted the stop command;
/// otherwise, `false`.
/// - error: The command or communication error, or `nil` on success.
- (void)stopFindDeviceWithCompletion:(AIBudsCompletionHandler _Nullable)completion;
@endInstance Method
Requests that the connected device stop its locate-device indication.
- Swift
- Objective-C
/// Requests that the connected device stop its locate-device indication.
/// - Parameters:
/// - completion: Called when command processing completes.
/// - success: `true` when the device accepted the stop command; otherwise,
/// `false`.
/// - error: The command or communication error, or `nil` on success.
func stopFindDevice(_ completion: AIBudsCompletionHandler?)/// Requests that the connected device stop its locate-device indication.
/// - Parameters:
/// - completion: Called when command processing completes.
/// - success: `true` when the device accepted the stop command; otherwise,
/// `false`.
/// - error: The command or communication error, or `nil` on success.
- (void)stopFindDeviceWithCompletion:(AIBudsCompletionHandler _Nullable)completion;Parameters
| Parameter | Type | Description |
|---|---|---|
completion | AIBudsCompletionHandler? | Optional handler called when command processing completes. |
Callback Parameters:
| Name | Type | Description |
|---|---|---|
success | Bool / BOOL | true when the device accepted the stop command; otherwise false. |
error | NSError? | The command or communication error, or nil on success. |
Return Value
This method does not return a value directly. The result is provided through the completion handler.
Usage Examples
- Swift
- Objective-C
import AIBuds
final class DeviceManager {
weak var device: DeviceConvertible?
func stopFindingDevice() {
guard let device = device as? DeviceFindAPI else {
print("Device does not support finding")
return
}
device.stopFindDevice { success, error in
guard success else {
print("Failed to stop finding: \(error?.localizedDescription ?? "Unknown error")")
return
}
print("Stop command accepted")
}
}
}#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>
id<AIBudsDeviceFindAPI> device = (id<AIBudsDeviceFindAPI>)self.device;
if (![device conformsToProtocol:@protocol(AIBudsDeviceFindAPI)]) {
NSLog(@"Device does not support finding");
return;
}
[device stopFindDeviceWithCompletion:^(BOOL success, NSError *_Nullable error) {
if (!success) {
NSLog(@"Failed to stop finding: %@", error.localizedDescription ?: @"Unknown error");
return;
}
NSLog(@"Stop command accepted");
}];Error Handling
Check success before showing that the stop command was accepted, and use error for command or communication failures. Do not assume fixed error codes that are not documented for the target device.
Best Practices
- Check Protocol Conformance: Verify
DeviceFindAPIsupport before calling the method. - Track UI State Locally: The protocol does not expose a property that reports whether finding is active.
- Update UI on the Main Queue: Dispatch UIKit updates from the completion handler to the main queue.
Notes
- The public API does not define the result of calling stop when no finding operation is active.
- The device-specific locate indication is outside this API contract.
- This stops the device-side indication. It does not stop an iPhone-side find-iPhone alert; that alert is owned by the host app.