Reputation: 41
Happens both on iOS 12
& iOS 13
.
I have Bluetooth-central
correctly added on my Info.plist
I'm specifying a list of service UUIDs
What I am seeing:
retrievePeripheralsWithIdentifiers:
and iOs can return the object "cached" then I can skip the scan and connect directly, which works perfectly. But sometimes retrievePeripheralsWithIdentifiers
: doesn't return the object so I can't always relay on that (And forces the user to interact with our device on the foreground first)Upvotes: 2
Views: 413
Reputation: 41
So, after quite a bit of back and forth between me and our firmware team, we found the reason behind our problems.
Turns out, apps on background when scanning won't read the advertisement extended packet. The problem was, the service UUID we were using to filter the scan for our devices was only being sent on that advertisement extended packet.
For this reason, when the app was scanning a new device, it would not find anything with that service UUID, but once it had found it with the app open, it would cache it internally with its services, and from that point it would work even while on background (because it already knows what services that device has).
The fix was to include that service UUID on the first advertisement packet.
Upvotes: 2