-
Notifications
You must be signed in to change notification settings - Fork 610
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
bug: iOS advertisment manufactuer data is not available when scanning while app is in background #1046
Comments
Hi @drolpi This sounds like a passive vs active scan difference: https://uynguyen.github.io/2020/08/23/Best-practice-Advanced-BLE-scanning-process-on-iOS/ If the advertisement data is important, you'll want to shift it from the scan response packet into the primary advertise packet 🙂 Unfortunately, there's nothing we can do from the plugin side. |
@peitschie what do you mean with "shift it from the scan response packet into the primary advertise packet"? |
On the peripheral side? |
@drolpi correct. This is a peripheral side change. This is the difference between the advertising packet (ADV_IND) and the scan response packet (SCAN_RSP): https://stackoverflow.com/questions/75292547/are-ble-devices-required-to-respond-to-a-scan-req-requests The fact this only shows up when the application is in the foreground means the peripheral only provides the data in the scan response. If it's critical to receive this data in the background, the only solution is for the peripheral to instead send the data in the advertising packet itself. |
You can see the distinction more clearly using something like nrf Connect (Android, but they may have an iPhone equivalent) |
With nrf connect on iOS the manufacturer data is always available |
My peripheral is a VanMoof S5 bike, which also has an original app that checks the manufacturer data in the background |
Are you able to post some screenshots of the packet structure as presented by nrf Connect? I'm specifically looking for the advertisement history (Scanner > select your peripheral > "More") so we can see what payloads are in each packet. Another common behaviour is that peripherals can rotate their advertising payloads. If this is the case, you'll need to build the handling for this as part of your own application. There is no general standard for how this occurs, so I can't implement any feature in the plugin. |
The manufacturer data was not available in the first packet, but only later, but I also went closer to it |
If this isnt what you mean, show me how it look on android |
This does keep pointing to this just being something your application needs to learn how to deal with, unfortunately 🙂 . |
Ok what would you suggest how I should implement this now? How can I listen to an advertisement change or how can I access updated versions of the advertisement? |
I'd recommend starting your scan using As per the docs:
This will trigger your callback every time the phone receives an advertising packet, and will always report the current advertising payloads. |
When I run a scan task while my app is in background the manufacturer data is not included in the advertisement data.
I am using capacitor v7 and iOS 18.3.
The text was updated successfully, but these errors were encountered: