Skip to main content

Send Navigation Information

Create a NavigationInfoModel for the current route step and send it to the device.

Prerequisites​

  • The device is connected and conforms to TurnByTurnNavigationAPI.
  • instruction and roadName are each no more than 128 bytes.
  • Distances and time use the units documented by the model.

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

See sendNavigationInfo in the API Reference.

PropertyMeaning
nextStepDistanceTextDisplay-ready text such as 300m or 1.5km.
maneuverRaw value defined by Navigation Maneuvers.
instructionInstruction text, maximum 128 bytes.
roadNameRoad name text, maximum 128 bytes.
alertInfoOptional NavigationAlertInfoModel; use the values and parameter rules in Navigation Alerts.
mapProviderRaw value defined by NavigationMapProvider.
transportModeRaw value defined by NavigationTransportMode.
remainingTimeRemaining time in seconds.
remainingDistanceRemaining distance in meters.

Usage Examples​

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​

Validate byte limits before sending. Use success as the primary result and preserve the device statusCode; the public SDK does not currently document individual status-code meanings.