即使安装了插件也无法使用串口蓝牙功能

Cannot use serialBluetooth functions even tough the plugin was installed

即使我在项目文件夹中通过 运行 cordova "plugin add cordova-plugin-bluetooth-serial" 命令安装了插件,我也无法使用 bluetoothSerial 功能。我没有收到任何错误,插件文件夹中存在该插件。

我尝试将插件标签添加到 config.xml、

我已经尝试将蓝牙权限添加到 AndroidManifest.xml

但 none 有所帮助。

我的cordova版本是9.0.0 (cordova-lib@9.0.1)


    var app = {

      initialize: function()

    {

    this.bindEvents();

    },

      bindEvents: function () 

    {

    document.addEventListener('deviceready',this.onDeviceReady(), 
    false)},
      onDeviceReady: function () {

        canvas.width = window.innerWidth;

        canvas.height = window.innerHeight;

    window.addEventListener('touchstart', function(event){

    console.log(event.touches);

          touchX = event.touches[0].pageX;

          touchY = event.touches[0].pageY;

          console.log(touchX, touchY);

          if (touchX <= button1.x + button1.width && touchX >= button1.x) 
    {
            if (touchY <= button1.y + button1.height && touchY >= 
    button1.y) {
                check = 1;  // Everything is fine until here. 
                bluetoothSerial.isEnabled(success(), fail()); // the code 
    here and below here is never executed. 
                c.font = "80px Arial";
                c.fillText("here",50,50);
        }
      }

当我使用 chrome://inspect/#devices 进行调试时,我收到:

 serialBluetooth is not defined error.

为什么会这样?

原来需要包含脚本标签,cordova.js。