Bluetooth devices could not be detected in the background on iOS 16.6.
Up until iOS16.0.3, the same code was able to detect Bluetooth devices.
Did the update between iOS 16.0.3 and iOS 16.6 put restrictions on Bluetooth scanning?
It is initiating a Bluetooh scan upon beacon detection. The beacon is detectable.
Below is the code.
func locationManager(_ manager: CLLocationManager, didDetermineState state: CLRegionState, for region: CLRegion) {
switch (state) {
case .inside:
print("StartBeaconNavigation: iBeacon inside")
myLocationManager.requestAlwaysAuthorization()
if(bleManager.linkState == .disconnected) {
_=bleManager.startScan()
}
break;
case .outside:
print("StartBeaconNavigation: iBeacon outside")
break;
case .unknown:
print("StartBeaconNavigation: iBeacon unknown")
break;
}
}
func startScan() -> Bool {
print("BTMana:startScan")
if( centralManager.state == .poweredOn ) {
if centralManager.isScanning == false {
let UUIDs: [CBUUID] = [systemServiceUUID]
let scanOptions = [CBCentralManagerScanOptionAllowDuplicatesKey: true]
centralManager.scanForPeripherals(withServices: UUIDs, options: scanOptions)
return true
} else {
print("BTMana:startScan NG for scanning...")
return false
}
} else {
print("BTMana:startScan NG for state is not powerdOn ")
return false
}
}
As above, we are specifying the UUID of the service when scanning.
Thank you in advance.