Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

CapacitorJS Sunmi v2Pro #28

Open
RichyFennell opened this issue Feb 25, 2021 · 2 comments
Open

CapacitorJS Sunmi v2Pro #28

RichyFennell opened this issue Feb 25, 2021 · 2 comments

Comments

@RichyFennell
Copy link

RichyFennell commented Feb 25, 2021

Hi there,
Trying to use this in my Capacitor project, seems to build fine but does not talk to printer.

npm i cordova-plugin-sunmi-inner-printer

//(Have not imported the package, should???
// import * as sunmi from 'cordova-plugin-sunmi-inner-printer'???

//have following after my angular imports:

declare var sunmiInnerPrinter: any;

//below in a function on a button

  ```
     try {
    console.log('trying to print');

    if (JSON.stringify(sunmiInnerPrinter) !== "{}") {
      //theres a problem
      console.log('Printer output',JSON.stringify(sunmiInnerPrinter));
    return;
    }
    // it is safe to use sunmiInnerPrinter here
    sunmiInnerPrinter.printerInit();

    console.log('status',JSON.stringify(sunmiInnerPrinter.getPrinterVersion()));
    sunmiInnerPrinter.printOriginalText("Hello Printer");
    } catch(err) {
    console.log("error: "+ JSON.stringify(err));
    }

> ng build
> npx cap sync

----
Copying capacitor.config.json in 1.34ms
⠼ copy  Found 1 Cordova plugin for android
    cordova-plugin-sunmi-inner-printer (1.1.0)
✔ copy in 389.04ms
✔ Updating Android plugins in 49.87ms
  Found 1 Capacitor plugin for android:
    @capacitor-community/fcm (1.0.8)
  Found 1 Cordova plugin for android
    cordova-plugin-sunmi-inner-printer (1.1.0)
✔ update android in 394.63ms
----

Run the Android project on my Sumni device I get the following message:
D/SunmiInnerPrinter: Service connected

But when I print nothing happens and I get the following logs:
I/Capacitor/Console: File: http://localhost/vendor.js - Line 86038 - Msg: trying to print
I/Capacitor/Console: File: http://localhost/vendor.js - Line 86038 - Msg: error: {}

Thank you in advance for your help. I've got a few of these devices now so keen to get it working if I can

Rich

Capacitor version 6.14.11
Angular 7.3.1
Ionic 5.4.16





@RichyFennell
Copy link
Author

Upon further investigation I am not sure the Sunmi V2 and V1 are compatible. Can anyone confirm?

@pilz97
Copy link

pilz97 commented May 2, 2023

@RichyFennell i have the same issue
I have a P2Pro where it works perfectly.
But on my V2s i noticed that
InnerPrinterManager.getInstance().bindService(applicationContext, innerPrinterCallback);

returns false

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants