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

Navigation जानकारी भेजें

मौजूदा route step के लिए NavigationInfoModel बनाएँ और device को भेजें।

आवश्यक शर्तें

  • Device connected हो और TurnByTurnNavigationAPI conform करता हो।
  • instruction और roadName में से हर value अधिकतम 128 bytes हो।
  • Distance और time में model द्वारा documented units उपयोग हों।

API Reference

Framework

AIBuds.xcframework

Protocol की घोषणा

Swift
/// Turn by turn navigation API
protocol TurnByTurnNavigationAPI: DeviceAPI {
    /// Send navigation info
    /// - Parameters:
    ///   - info: Navigation info
    ///   - completion: A closure that is called when the operation completes.
    ///     - success: `true` if the operation was successful; otherwise `false`.
    ///     - statusCode: The status code returned by the device. `nil` if the operation failed.
    ///     - error: An `NSError` object that describes the error that occurred, or `nil` if the operation was successful.
    func sendNavigationInfo(
        _ info: NavigationInfoModel,
        completion: AIBudsStatusCodeCompletionHandler?
    )
}

API Reference में sendNavigationInfo देखें।

Propertyअर्थ
nextStepDistanceText300m या 1.5km जैसा display-ready text।
maneuverNavigation निर्देश में defined raw value।
instructionअधिकतम 128 bytes का instruction text।
roadNameअधिकतम 128 bytes का road name।
alertInfoOptional NavigationAlertInfoModel; Navigation alerts के values और parameter rules उपयोग करें।
mapProviderNavigationMapProvider द्वारा defined raw value।
transportModeNavigationTransportMode द्वारा defined raw value।
remainingTimeबचा समय, seconds में।
remainingDistanceबची दूरी, meters में।

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

Swift
guard let device = device as? TurnByTurnNavigationAPI else { return }

let info = NavigationInfoModel()
info.nextStepDistanceText = "300m"
info.maneuver = NSNumber(value: NavigationManeuver.right.rawValue)
info.instruction = "Turn right"
info.roadName = "Market Street"
info.remainingTime = 420
info.remainingDistance = 1800

device.sendNavigationInfo(info) { success, statusCode, error in
    guard success else {
        print(error?.localizedDescription ?? "Navigation update failed")
        return
    }
    print("Navigation sent: \(statusCode?.stringValue ?? "Unavailable")")
}

Error handling

भेजने से पहले byte limits validate करें। success को primary result मानें और device statusCode सुरक्षित रखें; public SDK अभी individual status codes का अर्थ document नहीं करता।