Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failing to startNotifications and send some writes in a specific phone (works in most phones and some writes also work in the phone with the issue)

See original GitHub issue


First thanks for this plugin!

I’m having a peculiar issue, so I after connecting to my device I need to startNotifications for a specific service and also do some writes for some services, this is all working fine in most phones where we tested (all bellow Android 10 as far as I’m aware, and iPhones)… But in a One Plus phone with Android 12 it’s failing to startNotifications and failing to send a specific write request, there are some that are working, resolving in Characteristic not found, I’ve been doing some research and just can’t pin point it. It’s weird that it works with most phones and only some cases fail for this phone (although always the same ones). Using version 1.5.0 of your plugin.

Do you have any idea of what I can do to resolve this? If you need anymore information I can try to provide it.


Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

keruetercommented, Sep 13, 2022


i also encountered this issue and figured out that this issue happens on almost every Xiaomi or Motorola device which are on Android 12 or higher. Tested this on several devices from my colleagues.

So the BLE discovery works, but while calling startNotifications this will be thrown:

Characteristic not found.
at http://localhost/main.09c2e5e8ec33ac26.js:1:176017
at Generator.throw (<anonymous>)
at r (http://localhost/main.09c2e5e8ec33ac26.js:1:365888)
at Q (http://localhost/main.09c2e5e8ec33ac26.js:1:366134)
at v.invoke (http://localhost/polyfills.d6d588c4ebc94178.js:1:7705)
at Object.onInvoke (http://localhost/main.09c2e5e8ec33ac26.js:1:507104)
at v.invoke (http://localhost/polyfills.d6d588c4ebc94178.js:1:7645)
at (http://localhost/polyfills.d6d588c4ebc94178.js:1:2783)
at http://localhost/polyfills.d6d588c4ebc94178.js:1:18575
at v.invokeTask (http://localhost/polyfills.d6d588c4ebc94178.js:1:8389)

Works on iOS and also on a Google Pixel 4a and some Samsung devices with Android 11 and 12 though…

Unfortunately i don’t have a Xiaomi or Motorola device at home atm to go futher reproducing this behavior, but maybe this information helps a bit.

Fabchickcommented, Oct 13, 2022

On my app I experienced something very similar. Two phones with Android 12 (Xiaomi Mi 10T Lite and an other one which name I don’t know) had connection problems. Digging deeper it seemed like the call to getServices() right after connect() returned no services for these specific phones, which is necessary for startNotifications().

So in my research I found some things in these two links:

So it seems like some models with Android 12 make an automatic call, so if you make your own calls until it’s resolved it always returns an error.

Atm resolved it adding a delay of 1.5 secs. Would love to see a better resolution from someone 😄

After I read this I tested what happens if I add a 0.5s delay between connect() and getServices(). With this delay getServices() finally returns services and everything works fine now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

startNotifications error "Setting notification failed" #301 - GitHub
Writing to a BLE device characteristic and expecting to read notifications written to the characteristic. Using, serviceID, ...
Read more >
How to fix common smartphone problems - Popular Science
Most smartphone problems fall into just a few categories, like low battery life or buggy apps. Here's how to solve the most annoying...
Read more >
Cell Phone Unlocking | Federal Communications Commission
Unlocking a cell phone allows consumers to move their cell phone from one network to another compatible network. Some cell phones may contain...
Read more >
Communicating with Bluetooth devices over JavaScript
This article assumes you have some basic knowledge of how Bluetooth Low ... know when a Bluetooth device gets disconnected, and even read...
Read more >
Different behavior of chrome on desktop and android mobile ...
can you post snippet of your code? Also can you please post sample of data you are writing ? I am facing similar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found