Skip to main content

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 DeviceFindAPI protocol

API Reference

Framework

AIBuds.xcframework

Import

Swift
import AIBuds

Protocol

The stopFindDevice method is defined in DeviceFindAPI.

Swift
/// 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?)
}

Instance Method

Requests that the connected device stop its locate-device indication.

Swift
/// 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?)

Parameters

ParameterTypeDescription
completionAIBudsCompletionHandler?Optional handler called when command processing completes.

Callback Parameters:

NameTypeDescription
successBool / BOOLtrue when the device accepted the stop command; otherwise false.
errorNSError?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
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")
        }
    }
}

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

  1. Check Protocol Conformance: Verify DeviceFindAPI support before calling the method.
  2. Track UI State Locally: The protocol does not expose a property that reports whether finding is active.
  3. 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.