중지 Find Device
Request connected device 중지 its firmware-defined locate-device indication.
사전 요구 사항
전에 calling 이 API, ensure:
- 기기 입니다 connected 및 ready
- 기기 supports
DeviceFindAPIprotocol
API Reference
Framework
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>프로토콜
stopFindDevice method 입니다 defined 에서 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;
@end인스턴스 메서드
Requests connected device 중지 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;매개변수
| 매개변수 | 타입 | 설명 |
|---|---|---|
completion | AIBudsCompletionHandler? | 선택적 handler called 때 command processing completes. |
콜백 Parameters:
| 이름 | 타입 | 설명 |
|---|---|---|
success | Bool / BOOL | true 때 기기 accepted 중지 command; 그렇지 않으면 false. |
error | NSError? | command 또는 communication 오류, 또는 nil on 성공. |
반환값
이 method 하지 않습니다 반환 value directly. result 입니다 provided 통해 완료 핸들러.
사용 예제
- 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");
}];오류 처리
확인 success 전에 showing 중지 command was accepted, 및 사용 error 위한 command 또는 communication failures. 하지 마세요 assume fixed 오류 codes 입니다 아닌 documented 위한 target device.
권장 사항
- 확인 Protocol Conformance: 검증
DeviceFindAPIsupport 전에 calling method. - Track UI State Locally: protocol 하지 않습니다 expose property 보고서 whether finding 입니다 active.
- Update UI on 메인 큐: Dispatch UIKit updates 에서 완료 핸들러 메인 큐.
참고
- 공개 API 하지 않습니다 define result 의 calling 중지 때 no finding operation 입니다 active.
- 기기-specific locate indication 입니다 outside 이 API contract.
- 이 stops 기기-side indication. It 하지 않습니다 중지 iPhone-side find-iPhone alert; alert 입니다 owned by 호스트 앱.