Firstly: I have an iPad Air 2 and iPhone 7. For further reading, we evaluate that the application is active and open on the iPad and in the background on the iPhone. The application is exactly the same, even with the same Bluetooth service UUIDs and the same DataLocalNameKey.
I want to write an application that can advertise a bluetooth service in the background and can open this service (optimally and in the background). As I already read , I can’t use the beacon technology of apples, because there you can get only scanning / notification with beacons in the background (I tested this, it works fine) but not for advertising. So I started using CoreBluetooth, as described in the SO mentioned above, because there you can advertise in the background.
My application calls the didDiscoverPeripheral method in CBCentralManagerDelegate on the iPhone (the application is in the background), so it detected the iPad. The property isAdvertising CBPeripheralManager on the iPhone is true . But didDiscoverPeripheral not called an iPad. I am a bit confused. One option is that my iPad can no longer detect the iPhone for some reason, or my iPhone is lying and it is not being advertised.
So I thought I was just a little stupid and was looking for “CoreBluetooth debugging apps”. I found Vicinity and AltBeacon . And with both applications the behavior is the same! If you use the background (press the "home / sleep" button) of the advertising application, the viewing application will no longer be able to detect it. If you open a background application, it will instantly open it. Both applications mention that they can be broadcast in the background.
I am doing something wrong; is this behavior expected? I misunderstood the framework? Can you confirm this behavior?
To confirm this, the fastest way is to install Vicinity on two devices (you must add the NSBluetoothPeripheralUsageDescription key in Info.plist), install one device for broadcasting and press the home button.
source share