Reputation: 251
I am currently working on an app that requires me to scan a device using Bluetooth 4.0. At this point I have encounter a problem.
Is it possible to have the app scan the device when the app is running in the background? For some reason, the app cannot scan the device. The app did not call didDiscoverPeripheral while it was running in the background. However, my app can receive data from the device once connection has been establish.
To make things simpler, why can't my app scan the device while it is running in the background?
P.S. I did input the Required background modes 1.App communicates using CoreBluetooth 2.App shares data using CoreBluetooth
Upvotes: 5
Views: 2189
Reputation: 956
Another thing that may be an issue is that you must scan for specific services, like so:
[myCentralManager scanForPeripheralsWithServices:@[serviceUUID] options:nil];
rather than having that "with services" parameter be nil. I think this is a huge gotcha and is barely whispered in Apple's documentation, only mentioned in the description of that method, and nowhere in the Core Bluetooth Backgrounding document.
Upvotes: 0
Reputation: 16780
Scanning in the background is a very slow process. Apple says it's 55 times slower than in the foreground. My experience shows that it can be even slower. So in order to scan for a device in background keep in mind the following:
nil
services.Upvotes: 6
Reputation: 1
Put service or data in advertisement package! Also set advertisement periode fast if you want the iPhone to discover it faster. I use 20 ms for first 30 s. br henrik
Upvotes: 0