For an ionic 2 app to print using Sunmi V1, added native plugin for printer by executing
cordova plugin add cordova-plugin-printer
First I checked whether the printer is available by
checkPrinter() {
this.printer.check().then(function () {
alert("Printer available");
}, function () {
alert("Printer not available");
});
}
It alerts "Printer available"
But the below method doesn't prompt any message
printData() {
this.printer.isAvailable().then(function () {
this.printer.print("Test Data").then(function () {
alert("Printed");
}, function () {
alert("Printing error");
});
}, function () {
alert('Unavailable');
});
}
So I called Printer.print method directly as below
printData(){
this.printer.print("Test Data").then(function () {
alert("Printed");
}, function () {
alert("Printing Error");
});
}
This method opens Print dialog to choose printer
If I select 'All Printers' from the dropdown to select printer instead of 'Save as PDF', then the search screen appears and keeps on searching...
Is some configuration missing or is it possible to interact with POS printers using cordova printer plugin?
Thanks.
According to the documentation is not that easy:
http://docs.sunmi.com/htmls/index.html?lang=en##V1%20Docs%20&%20Resources
i found a new plugin created by labibramadhan. Thanks labib
you can find the plugin here
https://github.com/labibramadhan/cordova-sunmi-inner-printer
First, install by typing ionic
Then, use it on your cordova javascript codes by calling:
https://github.com/labibramadhan/cordova-sunmi-inner-printer/blob/master/www/innerprinter.js
Thank you
"Sunmi printer itself is not a network printer, web applications can not communicate directly with the printer, you need to accept data on the android applications" - From the documents available in their site. (I also contacted their support team but there was no proper reply)
As of now it doesn't support, so I am using github.com/shangmisunmi/SunmiPrinterDemo as example and developing the application in Android instead of ionic 2.