0

BluetoothLowEnergyAdapterApple: Call CBPeripheralManager::init, not initWithDelegate

The initWithDelegate calls are not available on tvOS, watchOS and
visionOS for some reason (the CBCentralManager equivalents are).

Switch to calling init and manually setting the `delegate` property
immediately afterwards; we were already using the main dispatch queue in
the `queue` parameter anyway, so this should not have any visible
side-effect.

Bug: 391914246
Change-Id: Ic5d023bb96cfe3ba83dcc9d08c84f8ef5250e87a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6312737
Commit-Queue: Raphael Kubo da Costa <kubo@igalia.com>
Reviewed-by: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1426624}
This commit is contained in:
Raphael Kubo da Costa
2025-02-28 16:21:15 -08:00
committed by Chromium LUCI CQ
parent d9cb871f13
commit 3fcd5f4ed4

@ -262,9 +262,11 @@ void BluetoothLowEnergyAdapterApple::LazyInitialize() {
}
low_energy_discovery_manager_->SetCentralManager(low_energy_central_manager_);
low_energy_peripheral_manager_ = [[CBPeripheralManager alloc]
initWithDelegate:low_energy_peripheral_manager_delegate_
queue:dispatch_get_main_queue()];
// Avoid using initWithDelegate:queue: directly because it is not available
// on tvOS, watchOS and visionOS.
low_energy_peripheral_manager_ = [[CBPeripheralManager alloc] init];
low_energy_peripheral_manager_.delegate =
low_energy_peripheral_manager_delegate_;
lazy_initialized_ = true;