Ionic 4 原生蓝牙低功耗 (BLE) 根本无法工作

Ionic 4 Native Bluetooth Low Energy (BLE) not working at all

我无法在 Android 或 iOS 上获得带有 latest Ionic (4) working with Ionic Native BLE 的项目。添加此插件时,应用程序会启动,但在启动画面后会完全空白。检查 DOM 时,app-root 是空的。

我做了什么:

    import { BLE } from '@ionic-native/ble';
    @NgModule({
      declarations: [...],
      imports: [...],
      bootstrap: [IonicApp],
      entryComponents: [...],
      providers: [
        ...,
        BLE
      ]
    })
    export class AppModule {}

我注意到失败点是将 BLE 添加到提供商列表时。如果没有它,该应用程序将正常启动。将BLE添加到列表后,出现白屏,应用程序无法完全启动。

由于这个问题可以用非常少的代码重现,我相信 BLE 插件存在根本性的错误。我希望被证明是错误的,但经过几个小时的搜索,我还是无法查清真相。

完全披露:我也试过 Ionic Native BluetoothLE, which has the same issue (which makes me believe even more that something is fundamentally wrong). BluetoothSerial 不会使应用程序崩溃,但它不提供我正在寻找的那种功能。

TL;DR:我使用的是旧 BLE 版本的缓存版本。


感谢 Aashay karekar 注意到我的包含路径已关闭。然而,当我使用正确的路径时,Ionic 无法找到指定的(但正确的)路径。这让我研究了版本控制,并手动从 package.json 中删除了 BLE,并删除了 node_modules 文件夹。当我再次安装 BLE 时,一切正常。