본문으로 건너뛰기

길 안내 정보 전송

현재 경로 단계에 맞는 NavigationInfoModel을 생성하여 기기로 전송합니다.

사전 요구 사항

  • 기기가 연결되어 있고 TurnByTurnNavigationAPI를 준수합니다.
  • instructionroadName은 각각 128 byte 이하여야 합니다.
  • 거리와 시간에는 모델에 정의된 단위를 사용합니다.

API 참고

프레임워크

AIBuds.xcframework

프로토콜

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 참고에서 sendNavigationInfo를 확인하세요.

길 안내 모델

속성의미
nextStepDistanceText300m 또는 1.5km처럼 화면에 바로 표시할 수 있는 텍스트입니다.
maneuver길 안내 동작에 정의된 raw value입니다.
instruction최대 128 byte의 안내 문구입니다.
roadName최대 128 byte의 도로명입니다.
alertInfo선택적 NavigationAlertInfoModel입니다. 길 안내 경고의 값과 매개변수 규칙을 따르세요.
mapProviderNavigationMapProvider에 정의된 raw value입니다.
transportModeNavigationTransportMode에 정의된 raw value입니다.
remainingTime남은 시간(초)입니다.
remainingDistance남은 거리(m)입니다.

사용 예제

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

오류 처리

전송하기 전에 byte 제한을 확인하세요. success를 기본 결과로 사용하고 기기의 statusCode를 보관하세요. 현재 공개 SDK에는 개별 상태 코드의 의미가 정의되어 있지 않습니다.