6

I trying to connect peripheral using UUID in the background, It's working only when i interact with advertising beacon first time at foreground then my app went background its working background and lock mode also if First time my app is away from advertising beacon i put my app at background then will come near to advertising beacon it's not working. in console, they came last peripheral not found as that error will come, my question is : is this possible to scan or connect Bluetooth using UUID for the first time without the app opening?

i already tried that solutions also :

iOS BLE device paired while app is in background or killed or suspend

iOS: didDiscoverPeripheral not called in Background mode

didDiscoverPeripheral: not working sometimes on background

Not able to search my BLE Device which is providing service ID in scan Response iOS

Source file : https://drive.google.com/file/d/1uVR_kA3NsQUpM-LLgrGgXCeZK6PBO-A7/view?usp=sharing

Developer1205
  • 167
  • 4
  • 23

1 Answers1

0

Found this question a bit interesting, so went about studying CoreBluetooth.

As per the Core bluetooth programming guide

Although you can perform many Bluetooth-related tasks while your app is in the background, keep in mind that scanning for peripherals while your app is in the background operates differently than when your app is in the foreground. In particular, when your app is scanning for device while in the background: The CBCentralManagerScanOptionAllowDuplicatesKey scan option key is ignored, and multiple discoveries of an advertising peripheral are coalesced into a single discovery event. If all apps that are scanning for peripherals are in the background, the interval at which your central device scans for advertising packets increases. As a result, it may take longer to discover an advertising peripheral.

Now in your provided sample the background modes are correctly provided. iOS looks for advertising packets only in background [Passive] mode and not the response packets Searching further bought me to this link

ios- Scan and connect to BLE peripheral in background

You can check and see if this too is the case with you

nps
  • 46
  • 4