How to hide the Bluetooth Alert in Swift

Oscar de la Hera Gomez
Three flowers that represent Swift, Bluetooth and XCode side by side. Beneath them sits the text "Hide Bluetooth Power Alert."

If an app tries to use Bluetooth and Bluetooth is turned off or permissions are denied, a pop-up will appear prompting the user to allow Bluetooth in Settings.

To stop the alert from appearing, initialize the CBCentralManager with options that include the CBCentralManagerOptionShowPowerAlertKey set to false.

The Problem

As of October 2023, Apple does not provide a way to determine if a user has granted Bluetooth permissions to an app or if Bluetooth is turned on, on a device.

In order to determine the Bluetooth status, a Swift app (i.e. iOS, iPadOS, MacOS, TVOS, WatchOS, VisionOS) must create a CBCentralManager and consult its state using the centralManagerDidUpdateState delegate function.

In the event that Bluetooth is not authorized or it is not powered on, the user will experience the alert shown below.

A screenshot of an iPhone app showing the alert that appears if an app tries to access Bluetooth when permissions are denied or Bluetooth is turned off. It states "The app would like to use Bluetooth for new connections. You can allow new connections in Settings." It also offers two buttons - "Settings" and "Close." If you press the settings button, it takes you to the settings for the App, whilst pressing the close button closes the modal.

The Solution

To stop the pop up from appearing, you must initialize the CBCentralManager with options that include the CBCentralManagerOptionShowPowerAlertKey set to false.

let centralManager: CBCentralManager = CBCentralManager(delegate: self, queue: nil, options: [CBCentralManagerOptionShowPowerAlertKey: false]);

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details