डिवाइस ढूँढना रोकें
जुड़े डिवाइस से उसका firmware-defined locate indication बंद करने का अनुरोध करें।
पहले की आवश्यकताएँ
यह API call करने से पहले सुनिश्चित करें:
- डिवाइस connected और ready है
- डिवाइस
DeviceFindAPIprotocol का समर्थन करता है
API संदर्भ
फ्रेमवर्क
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>प्रोटोकॉल
stopFindDevice method, 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
जुड़े डिवाइस से locate 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;पैरामीटर
| पैरामीटर | प्रकार | विवरण |
|---|---|---|
completion | AIBudsCompletionHandler? | Command processing पूरा होने पर call होने वाला optional handler। |
Callback पैरामीटर:
| नाम | प्रकार | विवरण |
|---|---|---|
success | Bool / BOOL | डिवाइस ने stop command स्वीकार किया हो तो true, अन्यथा false। |
error | NSError? | Command या communication error; सफल होने पर nil। |
Return value
यह method सीधे कोई value return नहीं करता। परिणाम completion handler से मिलता है।
उपयोग के उदाहरण
- 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
Stop command accepted दिखाने से पहले success जाँचें और command या communication failure के लिए error उपयोग करें। लक्ष्य डिवाइस के लिए documented न होने वाले fixed error codes न मानें।
बेहतर तरीके
- Protocol conformance जाँचें: Method call करने से पहले
DeviceFindAPIsupport की पुष्टि करें। - UI state local रूप से रखें: Protocol यह बताने वाली property नहीं देता कि finding active है या नहीं।
- 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 नहीं रुकता; वह होस्ट ऐप के नियंत्रण में है।