randdusing / cordova-plugin-bluetoothle

Bluetooth Low Energy Phonegap Plugin
804 stars 354 forks source link

Bluetoothle is not defined #480

Open Trauck opened 6 years ago

Trauck commented 6 years ago

Hi, I added this plugin to connect in bluetooth to a device. So I ran the installation "cordova plugin add cordova-plugin-bluetoothle", then I try to use it in my javascript related to my html page. But when I build on my device, nothing happens like when there is a js error. Here but version of android and cordova: android 6.4.0, cordova 8.0.0. I call bluetoothle like this in my scripts: image

I have already try to remove and re add the plugin, nothing works, i watch other issues but no ones help me. I can see the plugin is added in my cordova_plugins.js, cordova.js and my config.xml. I think the problem comes from the way I call bluetoothle in my script.

randdusing commented 6 years ago

You're probably calling plugin code before the plugin is actually ready. Are you waiting for the cordova ready event?

Trauck commented 6 years ago

Yes sure, i make the same thing with "$(document).ready(function(){ ... ".

randdusing commented 6 years ago

That's when jquery is safe to use, not cordova plugins. I forgot the event name off the top of my head, but check out the example in the Angular wrapper

Trauck commented 6 years ago

It's good, finally everything worked very well I forgot the addition of a script (cordova.js).

I still have a new question. When I press a button on my application I launch my bluetooth connection, my bluetooth is activated very well, but then I would like to show the list of possible connections. How to do this ? I try with the Scan but when I run it, nothing appears.

And what is the function that turns off the bluetooth of the phone?

DonOzOn commented 2 years ago

It's good, finally everything worked very well I forgot the addition of a script (cordova.js).

I still have a new question. When I press a button on my application I launch my bluetooth connection, my bluetooth is activated very well, but then I would like to show the list of possible connections. How to do this ? I try with the Scan but when I run it, nothing appears.

And what is the function that turns off the bluetooth of the phone?

HI Trauck , I face to same issue , can you show me how you addition of a script (cordova.js)? Thanks so much