鍍金池/ 問答/HTML5  網(wǎng)絡(luò)安全  HTML/ ionic3藍(lán)牙cordova-plugin-bluetooth-serial報

ionic3藍(lán)牙cordova-plugin-bluetooth-serial報錯

計劃在安卓ionic項目中打開藍(lán)牙,搜索藍(lán)牙,并保存。
使用的是 cordova-plugin-bluetooth-serial
這里是官方文檔 https://www.npmjs.com/package...

在使用搜索藍(lán)牙方法時直接報錯了,跟著網(wǎng)上文檔寫的

searchBlueTooth(){
    this.bluetoothSerial.discoverUnpaired(function(devices) {
          devices.forEach(function(device) {
            console.log(device.id);
          })
        }, failure);
}

使用打開藍(lán)牙方法可以正常使用

this.bluetoothSerial.enable();

以下是對比圖

clipboard.png

clipboard.png
有沒有人指點(diǎn)一下

回答
編輯回答
只愛你

沒用過藍(lán)牙,不過從文檔上看好像沒問題,不過在ionic的文檔上看這個函數(shù)返回的是Promise,要不你試試

this.bluetoothSerial.discoverUnpaired().then(devices =>{.....})

或者把報錯的圖發(fā)出來看看

clipboard.png

2017年3月23日 02:27
編輯回答
赱丅呿

返回的是promise,在瀏覽器調(diào)試會報錯,只能打包到設(shè)備調(diào)試

2017年3月12日 09:19