View in English

  • Apple 开发者
    • 入门汇总

    探索“入门汇总”

    • 概览
    • 学习
    • Apple Developer Program

    及时了解最新动态

    • 最新动态
    • 开发者你好
    • 平台

    探索“平台”

    • Apple 平台
    • iOS
    • iPadOS
    • macOS
    • Apple tvOS
    • visionOS
    • watchOS
    • App Store

    精选

    • 设计
    • 分发
    • 游戏
    • 配件
    • 网页
    • Home
    • CarPlay 车载
    • 技术

    探索“技术”

    • 概览
    • Xcode
    • Swift
    • SwiftUI

    精选

    • 辅助功能
    • App Intents
    • Apple 智能
    • 游戏
    • 机器学习与 AI
    • 安全性
    • Xcode Cloud
    • 社区

    探索“社区”

    • 概览
    • “与 Apple 会面交流”活动
    • 社区主导的活动
    • 开发者论坛
    • 开源

    精选

    • WWDC
    • Swift Student Challenge
    • 开发者故事
    • App Store 大奖
    • Apple 设计大奖
    • Apple Developer Centers
    • 文档

    探索“文档”

    • 文档库
    • 技术概述
    • 示例代码
    • 《人机界面指南》
    • 视频

    发布说明

    • 精选更新
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • Apple tvOS
    • Xcode
    • 下载

    探索“下载”

    • 所有下载
    • 操作系统
    • 应用程序
    • 设计资源

    精选

    • Xcode
    • TestFlight
    • 字体
    • SF Symbols
    • Icon Composer
    • 支持

    探索“支持”

    • 概览
    • 帮助指南
    • 开发者论坛
    • “反馈助理”
    • 联系我们

    精选

    • 《开发者账户帮助》
    • 《App 审核指南》
    • 《App Store Connect 帮助》
    • 即将实行的要求
    • 协议和准则
    • 系统状态
  • 快速链接

    • 活动
    • 新闻
    • 论坛
    • 示例代码
    • 视频
 

视频

打开菜单 关闭菜单
  • 专题
  • 所有视频
  • 关于

更多视频

  • 简介
  • 概要
  • 代码
  • 通过 Bluetooth Channel Sounding 查找你的配件

    开始使用 Channel Sounding,为你的蓝牙配件带来距离和方向感知功能。深入探索全新的 Nearby Interaction 和 Core Bluetooth API,并详细了解你需要进行哪些配件端更改。在优化功耗的同时,确保顺畅灵敏的体验。

    章节

    • 0:01 - Introduction
    • 0:50 - Overview
    • 3:17 - Core Bluetooth API
    • 4:34 - Nearby Interaction API
    • 7:05 - Hardware tips

    资源

    • AccessorySetupKit
    • Nearby Interaction
    • Core Bluetooth
      • 高清视频
      • 标清视频

    相关视频

    WWDC24

    • 了解 AccessorySetupKit

    WWDC21

    • 探索与第三方配件的 Nearby Interaction
  • 搜索此视频…
    • 3:43 - Start a Core Bluetooth Channel Sounding session

      import CoreBluetooth
      
      func isChannelSoundingSupported() -> BOOL {
          guard centralManager.state == .poweredOn else { return }
          if #available(iOS 27.0, *) {
              // Check current device supports Bluetooth Channel Sounding
              return CBCentralManager.supportsFeatures(.channelSounding)
          }
      }
      
      func startChannelSounding(_ peripheral: CBPeripheral) {
          guard peripheral.isConnected else { return }
          if #available(iOS 27.0, *) {  
              // Step 1: Create a CBChannelSoundingSessionConfiguration
              let config = CBChannelSoundingSessionConfiguration(role: .initiator)
      
              // Step 2: Start the channel sounding session
              peripheral.startChannelSoundingSession(config)
          }
      }
    • 4:09 - Receive distance results and cancel a session

      import CoreBluetooth
      
      // Receive distance results
      func peripheral(_ peripheral: CBPeripheral,
                      didReceive results: CBChannelSoundingProcedureResults?,
                      error: Error?) {
          guard let results = results else { return }
      
          let distance = results.distance
          
          // Do something with distance
      }
      
      // Cancel a Channel Sounding session
      func cancelChannelSounding(_ peripheral: CBPeripheral) {
          guard peripheral.isConnected else { return }
          if #available(iOS 27.0, *) {
              // Cancel the channel sounding session
              peripheral.cancelChannelSoundingSession(config)
          }
      }
      
      func peripheral(_ peripheral: CBPeripheral,
                      didCompleteChannelSoundingSession error: Error?) {   
          // Session is complete
      }
    • 4:41 - Start a Nearby Interaction Channel Sounding session

      import CoreBluetooth
      import NearbyInteraction
      
      // Configure a Nearby Interaction Channel Sounding session
      func startChannelSoundingThroughNearbyInteraction(_ peripheral: CBPeripheral) {
          if #available(iOS 27.0, *) {        
              // Step 1: Check current device supports Bluetooth Channel Sounding
              guard NISession.deviceCapabilities.supportsBluetoothChannelSounding else { return }
      
              // Step 2: Create an NINearbyAccessoryConfiguration
              let config = NINearbyAccessoryConfiguration(
                  bluetoothChannelSoundingIdentifier: peripheral.identifier, 
                  previousChannelSoundingIdentifier: nil)
      
              // Step 3: Enable camera assistance for direction support
              if NISession.deviceCapabilities.supportsCameraAssistance { 
                  config.isCameraAssistanceEnabled = true
              }
          }
      }
    • 5:19 - Run a Nearby Interaction Channel Sounding session

      import CoreBluetooth
      import NearbyInteraction
      
      // Run a Nearby Interaction Channel Sounding session
      func runChannelSoundingThroughNearbyInteraction(_ config: NINearbyAccessoryConfiguration) {
          // Create an NISession
          let session = NISession()
          session.delegate = self
          // Run the NISession with the accessory configuration
          session.run(config)
      }
      
      // Improve Nearby Interaction direction outputs
      func updateAccessoryMotionState(_ isMoving: Bool) {
          NIMotionActivityState motionState = isMoving ? .moving : .stationary
          
          // Tell NISession about.the accessory's motion state
          session.updateMotionState(motionState, forObjectWithToken: object.discoveryToken)
      }
      
      // Receive NISession updates
      func session(_ session: NISession, didUpdate nearbyObjects: [NINearbyObjects]) {   
          guard let object = nearbyObjects.first else { return }
      
          if let distance = object.distance {
              // Do something with distance
          }
      
          if let direction = object.horizontalAngle {
              // Do something with horizontal angle
          }
      }
    • 0:01 - Introduction
    • Discover the three aspects of Bluetooth Channel Sounding that will be discussed in this video.

    • 0:50 - Overview
    • Find inspiration for using Bluetooth Channel Sounding.

    • 3:17 - Core Bluetooth API
    • Learn how to get distance with the Core Bluetooth API.

    • 4:34 - Nearby Interaction API
    • Get distance and direction with the Nearby Interaction API.

    • 7:05 - Hardware tips
    • Understand the hardware requirements for Bluetooth Channel Sounding.

Developer Footer

  • 视频
  • WWDC26
  • 通过 Bluetooth Channel Sounding 查找你的配件
  • 打开菜单 关闭菜单
    • iOS
    • iPadOS
    • macOS
    • Apple tvOS
    • visionOS
    • watchOS
    打开菜单 关闭菜单
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • SF Symbols
    打开菜单 关闭菜单
    • 辅助功能
    • 配件
    • Apple 智能
    • App 扩展
    • App Store
    • 音频与视频 (英文)
    • 增强现实
    • 设计
    • 分发
    • 教育
    • 字体 (英文)
    • 游戏
    • 健康与健身
    • App 内购买项目
    • 本地化
    • 地图与位置
    • 机器学习与 AI
    • 开源资源 (英文)
    • 安全性
    • Safari 浏览器与网页 (英文)
    打开菜单 关闭菜单
    • 完整文档 (英文)
    • 部分主题文档 (简体中文)
    • 教程
    • 下载
    • 论坛 (英文)
    • 视频
    打开菜单 关闭菜单
    • 支持文档
    • 联系我们
    • 错误报告
    • 系统状态 (英文)
    打开菜单 关闭菜单
    • Apple 开发者
    • App Store Connect
    • 证书、标识符和描述文件 (英文)
    • 反馈助理
    打开菜单 关闭菜单
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program (英文)
    • Mini Apps Partner Program
    • News Partner Program (英文)
    • Video Partner Program (英文)
    • 安全赏金计划 (英文)
    • Security Research Device Program (英文)
    打开菜单 关闭菜单
    • 与 Apple 会面交流
    • Apple Developer Center
    • App Store 大奖 (英文)
    • Apple 设计大奖
    • Apple Developer Academies (英文)
    • WWDC
    阅读最近新闻。
    获取 Apple Developer App。
    版权所有 © 2026 Apple Inc. 保留所有权利。
    使用条款 隐私政策 协议和准则