Ana içeriğe geç

Cihaz Bulmayı Durdurma

Bağlı cihazdan firmware tarafından tanımlanan bulma uyarısını durdurmasını isteyin.

Ön Koşullar

Bu API’yi çağırmadan önce şunları doğrulayın:

  • Cihaz bağlı ve hazırdır
  • Cihaz DeviceFindAPI protokolünü destekler

API Referansı

Framework

AIBuds.xcframework

İçe Aktarma

Swift
import AIBuds

Protokol

stopFindDevice yöntemi DeviceFindAPI içinde tanımlanır.

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

Örnek Yöntemi

Bağlı cihazdan bulma uyarısını durdurmasını ister.

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

Parametreler

ParametreTürAçıklama
completionAIBudsCompletionHandler?Komut işleme tamamlandığında çağrılan isteğe bağlı işleyici.

Callback Parametreleri:

AdTürAçıklama
successBool / BOOLCihaz durdurma komutunu kabul ettiyse true; aksi takdirde false.
errorNSError?Komut ya da iletişim hatası; başarılıysa nil.

Dönüş Değeri

Bu yöntem doğrudan değer döndürmez. Sonuç completion işleyicisi aracılığıyla sağlanır.

Kullanım Örnekleri

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")
        }
    }
}

Hata Yönetimi

Durdurma komutunun kabul edildiğini göstermeden önce success değerini denetleyin; komut veya iletişim hatalarında error kullanın. Hedef cihaz için belgelenmemiş sabit hata kodları varsaymayın.

En İyi Uygulamalar

  1. Protokol Uyumluluğunu Denetleyin: Yöntemi çağırmadan önce DeviceFindAPI desteğini doğrulayın.
  2. Arayüz Durumunu Yerel Olarak İzleyin: Protokol bulma işleminin etkin olup olmadığını bildiren bir özellik sunmaz.
  3. Kullanıcı Arayüzünü Ana Kuyrukta Güncelleyin: Completion işleyicisindeki UIKit güncellemelerini ana kuyruğa yönlendirin.

Notlar

  • Genel API, etkin bir bulma işlemi yokken durdurma çağrısının sonucunu tanımlamaz.
  • Cihaza özgü bulma uyarısı bu API sözleşmesinin kapsamı dışındadır.
  • Bu işlem cihaz tarafındaki uyarıyı durdurur. iPhone tarafındaki iPhone bulma uyarısını durdurmaz; bu uyarı ana uygulama tarafından yönetilir.