蓝牙连接时调用 connect 但是偶然会没有系统回调

Asked on 03/03/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.