Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 16.4.1 - scan not returning a local name #527

Open
ASHBAW opened this issue Apr 24, 2023 · 9 comments
Open

iOS 16.4.1 - scan not returning a local name #527

ASHBAW opened this issue Apr 24, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@ASHBAW
Copy link

ASHBAW commented Apr 24, 2023

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 ASHBAW changed the title iOS 14.16.1 - scan only returning local name, not device name iOS 14.16.1 - scan not returning a local name Apr 24, 2023
@ASHBAW
Copy link
Author

ASHBAW commented Apr 25, 2023

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 ASHBAW changed the title iOS 14.16.1 - scan not returning a local name iOS 16.4.1 - scan not returning a local name Apr 25, 2023
@kerueter
Copy link

kerueter commented Apr 26, 2023

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

@ASHBAW
Copy link
Author

ASHBAW commented Apr 26, 2023

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?

@eppleton
Copy link

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.

@LgArcida
Copy link

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

@manncr
Copy link

manncr commented Apr 1, 2024

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

@TheNotorius0
Copy link

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') {

}

@mmalliotakisBiopix
Copy link

we have a similar issue .
we run the same code in android and iOS .

android:

await BleClient.requestLEScan({
          services: ["000012ab-0000-1000-8000-00805f9b34fb"], 
          allowDuplicates: false,
        }, (result: ScanResult) => {
          // This callback will be invoked for each device found
          this.logs.add('[+] Device found while scanning: ' + JSON.stringify(result));
          this.bluetoothService.addDevice(result);
        });

ios:

await BleClient.requestLEScan({
          services: ["000012ab-0000-1000-8000-00805f9b34fb",numberToUUID(0x12AB)],
          allowDuplicates: false,
        }, (result) => {...}

in android works fine:

image

but in ios we get generic name, no localName and no advertismentdata
image

@peitschie
Copy link
Collaborator

Hi @mmalliotakisBiopix

Are you able to grab the raw advertising payload using nrf Connect on Android, to confirm which flags and the GAP name being communicated here?

This sounds like the distinction between the GAP name and the advertised name. This link posted by @manncr is worth reading through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants