bluetooth-le icon indicating copy to clipboard operation
bluetooth-le copied to clipboard

iOS 16.4.1 - scan not returning a local name

Open ASHBAW opened this issue 1 year ago • 9 comments

After updating an iPhone to 16.4.1, which was released a couple of weeks ago, I noticed that after performing a scan that the scan is not returning a local name.

Is anyone else seeing this issue?

ASHBAW avatar Apr 24 '23 16:04 ASHBAW

Here is some additional information. We have a default device name - 'Hickory'. This is currently what is appearing after a scan with the plugin in our app with iOS 16.4.1. We set the local name to the serial number of the device. This serial number is what has been displayed after a scan with the plugin in prior iOS versions.

When I use a "generic" Bluetooth app (Light Blue) on an Apple device I get the following:

pic1

As you can see it has a serial number in the local name. This is the expected behavior.

If I set a breakpoint in Xcode within the plugin's getScanResult() function I get "nil" as the result of the local name, not the serial number - 2619W0589 I get with the generic Bluetooth app.

Screenshot 2023-04-25 at 8 30 06 AM

If I use an Apple device with an older version of iOS I get the correct local name 2619W0589:

Screenshot 2023-04-25 at 8 38 59 AM

Any insight as to what can be done to get this functionality working as before?

Thanks,

Brent

ASHBAW avatar Apr 25 '23 13:04 ASHBAW

On my side, the local name is present, but after the update to iOS 16.4.1, the manufacturer data is missing. Tested on another phone with iOS 13.x and there it worked. After the update to iOS 16.4.1 the already mentioned issue appeared as well on the other device.

image

kerueter avatar Apr 26 '23 07:04 kerueter

I had posted to several forums. about this. One suggestion was to add scan option - allowDuplicates.

Normally scans will discard the second and subsequent advertisements from a single device. If you need to receive them, set allowDuplicates to true (only applicable in requestLEScan). (default: false)

It works, though you get duplicates as per the flag.

Not sure why this would work?

ASHBAW avatar Apr 26 '23 15:04 ASHBAW

I can confirm that I see this issue on some devices, but not others. I think it might be related to how iOS caches BLE Devices. On iPhones that had scanned the BLE device before I do not have this issue (and #528). The issue only occurred on devices that did scan the device for the first time.

eppleton avatar Apr 26 '23 16:04 eppleton

Its been a while and a release (3.1.1) any update on this?

LgArcida avatar Dec 20 '23 15:12 LgArcida

I can confirm that I see this issue on some devices, but not others. I think it might be related to how iOS caches BLE Devices. On iPhones that had scanned the BLE device before I do not have this issue (and #528). The issue only occurred on devices that did scan the device for the first time.

We had a similar issue pop up where a renamed device wouldn't appear in a name-filtered scan. We were able to reproduce it by connecting to a device for the first time, renaming the device, and then attempt to connect to it again. Seemed linked to the cache, like you suggested. Clearing it fixed the issue. We did it via some other app that inadvertently cleared it when scanning for devices.

Edit: Followed a few thread chains, and stumbled across this apple dev forum post with a response here that explains it a little better. TL;DR is there's 2 places the localname can be - advertisement and in the device's GAP. It isn't guaranteed to be in the advertisement, so kCBAdvDataLocalName won't exist in the scan response, explaining why it shows up as nil in the response. As to why it doesn't happen on older versions of iOS, I'm not sure yet

manncr avatar Apr 01 '24 17:04 manncr

I've found this issue too and I fixed it. On iOS 16.4.1+ you should check for result.device.name.

So, in your code (let's say you are doing a condition based on the name), you should write this:

if (result?.localName === 'your-service-name' || result?.device?.name === 'your-service-name') {

}

TheNotorius0 avatar Jul 12 '24 10:07 TheNotorius0