蓝牙连接时调用 connect 但是偶然会没有系统回调
Generated on 3/3/2025
1 search
It seems like you are experiencing issues with Bluetooth connections where the connect
call occasionally does not trigger a system callback. This could be related to changes in how Bluetooth permissions and connections are managed in iOS 18, as discussed in the WWDC sessions.
In iOS 18, the introduction of the AccessorySetupKit streamlines the process of connecting to Bluetooth and Wi-Fi accessories. This new framework combines multiple permissions into a single flow, which might affect how callbacks are handled if your app hasn't fully transitioned to using this new setup.
Here are some key points from the sessions that might help:
-
AccessorySetupKit: This new framework simplifies the process of pairing and managing Bluetooth and Wi-Fi accessories. It ensures that the CB central manager state is only powered on when your app has paired accessories, which might affect when callbacks are triggered. You can learn more about this in the session Meet AccessorySetupKit.
-
Bluetooth Permissions: iOS 18 has updated the Bluetooth permission prompts to enhance user privacy. This might affect how and when your app can connect to Bluetooth devices. The session What’s new in privacy covers these changes in detail.
If your app is not yet using AccessorySetupKit, consider transitioning to it for a more consistent and streamlined experience. Additionally, ensure that your app handles Bluetooth permissions correctly under the new iOS 18 guidelines.

Migrate your app to Swift 6
Experience Swift 6 migration in action as we update an existing sample app. Learn how to migrate incrementally, module by module, and how the compiler helps you identify code that’s at risk of data races. Discover different techniques for ensuring clear isolation boundaries and eliminating concurrent access to shared mutable state.

Meet AccessorySetupKit
Elevate your accessory setup experience with AccessorySetupKit. Display a beautiful pairing dialog with an image of your Bluetooth or Wi-Fi accessory — no trip to the Settings app required. Discover how to improve privacy by pairing only your app with an accessory. And learn how you can migrate existing accessories so they can be managed by AccessorySetupKit.

What’s new in privacy
At Apple, we believe privacy is a fundamental human right. Learn about new and improved permission flows and other features that manage data in a privacy-preserving way, so that you can focus on creating great app experiences.

Enhance your UI animations and transitions
Explore how to adopt the zoom transition in navigation and presentations to increase the sense of continuity in your app, and learn how to animate UIKit views with SwiftUI animations to make it easier to build animations that feel continuous.

Go small with Embedded Swift
Embedded Swift brings the safety and expressivity of Swift to constrained environments. Explore how Embedded Swift runs on a variety of microcontrollers through a demonstration using an off-the-shelf Matter device. Learn how the Embedded Swift subset packs the benefits of Swift into a tiny footprint with no runtime, and discover plenty of resources to start your own Embedded Swift adventure.

What’s new in location authorization
Location authorization is turning 2.0. Learn about new recommendations and techniques to get the authorization you need, and a new system of diagnostics that can let you know when an authorization goal can’t be met.