मुख्य कंटेंट तक स्किप करें

डिवाइस ढूँढना रोकें

जुड़े डिवाइस से उसका firmware-defined locate indication बंद करने का अनुरोध करें।

पहले की आवश्यकताएँ

यह API call करने से पहले सुनिश्चित करें:

  • डिवाइस connected और ready है
  • डिवाइस DeviceFindAPI protocol का समर्थन करता है

API संदर्भ

फ्रेमवर्क

AIBuds.xcframework

Import

Swift
import AIBuds

प्रोटोकॉल

stopFindDevice method, 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

जुड़े डिवाइस से locate 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?)

पैरामीटर

पैरामीटरप्रकारविवरण
completionAIBudsCompletionHandler?Command processing पूरा होने पर call होने वाला optional handler।

Callback पैरामीटर:

नामप्रकारविवरण
successBool / BOOLडिवाइस ने stop command स्वीकार किया हो तो true, अन्यथा false
errorNSError?Command या communication error; सफल होने पर nil

Return value

यह method सीधे कोई value return नहीं करता। परिणाम completion handler से मिलता है।

उपयोग के उदाहरण

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

Stop command accepted दिखाने से पहले success जाँचें और command या communication failure के लिए error उपयोग करें। लक्ष्य डिवाइस के लिए documented न होने वाले fixed error codes न मानें।

बेहतर तरीके

  1. Protocol conformance जाँचें: Method call करने से पहले DeviceFindAPI support की पुष्टि करें।
  2. UI state local रूप से रखें: Protocol यह बताने वाली property नहीं देता कि finding active है या नहीं।
  3. UI को main queue पर अपडेट करें: Completion handler से UIKit updates main queue पर भेजें।

ध्यान देने योग्य बातें

  • कोई finding operation active न होने पर stop call करने का परिणाम public API परिभाषित नहीं करता।
  • डिवाइस-विशिष्ट locate indication इस API contract के बाहर है।
  • यह केवल device-side indication रोकता है। iPhone-side find-iPhone alert नहीं रुकता; वह होस्ट ऐप के नियंत्रण में है।