首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用ionic 3连接蓝牙打印机?

如何使用ionic 3连接蓝牙打印机?
EN

Stack Overflow用户
提问于 2017-10-26 14:23:32
回答 2查看 9.3K关注 0票数 0

我无法使用以下插件连接蓝牙打印机

代码语言:javascript
运行
复制
$ ionic cordova plugin add de.appplant.cordova.plugin.printer
$ npm install --save @ionic-native/printer

有没有办法用ionic 3连接蓝牙打印机?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-12-13 17:34:49

下面是一个使用ionic 2+打印到蓝牙收据打印机的示例。我写这篇文章是因为我遇到了同样的问题。

所以我试着使用ionic原生蓝牙串行连接'write‘来打印,它起作用了。

它应该也能在ionic 3上工作:

https://github.com/razmans/ionicBluetoothPrint

票数 4
EN

Stack Overflow用户

发布于 2018-03-30 21:46:56

请执行以下3个步骤:1-查找蓝牙设备,2-使用设备id连接设备,3-打印

代码语言:javascript
运行
复制
devices = [];
btnFindDevices() {
   this.bluetoothSerial.isEnabled().then(() => {
   this.bluetoothSerial.discoverUnpaired().then((allDevices) => {
   this.devices = allDevices;
   console.log(allDevices);
});
});
}

btnBlueToothConnect() {
   if (this.devices.length > 0) {
   //this code connects device which’s position is 0. Change it whatever you 
   //want.
   this.bluetoothSerial.connect(this.devices[0].id).subscribe((data) => {
   console.log(“Connected”, data);
   }, (error) => {
   console.log(“not Connected”, error);
   });
    }
    else {
    console.log(“Device List did not genereted yet.”);
    }
    }

    btnBlueToothPrint() {
    //Attention… Bluetooth printer prints data when whole line filled. For 
    //example in my case printer is 32 colon,
    //“hello world” has 11 characters. so it prints after 3 times clicked 
    //the print button.
        this.bluetoothSerial.write(‘hello world’).then(() => { console.log(“s”); }, () => { console.log(“f”); });
    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46947164

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档