Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi, I need to use react-native-zebra-bluetooth-printer with my application which is expo managed, I got this error [Unhandled promise rejection: TypeError: Cannot read property 'init' of undefined] #18

Open
ImanSharabatiHM opened this issue Jul 8, 2023 · 12 comments

Comments

@ImanSharabatiHM
Copy link

ImanSharabatiHM commented Jul 8, 2023

Tasks

Preview Give feedback
No tasks being tracked yet.
@ImanSharabatiHM ImanSharabatiHM changed the title Hi, Hi, I need to use react-native-zebra-bluetooth-printer with my application which is expo managed, Jul 8, 2023
@ImanSharabatiHM ImanSharabatiHM changed the title Hi, I need to use react-native-zebra-bluetooth-printer with my application which is expo managed, Hi, I need to use react-native-zebra-bluetooth-printer with my application which is expo managed, I got this error [Unhandled promise rejection: TypeError: Cannot read property 'init' of undefined] Jul 8, 2023
@ImanSharabatiHM
Copy link
Author

"dependencies": {
"@config-plugins/react-native-blob-util": "^5.0.0",
"@config-plugins/react-native-pdf": "^5.0.0",
"@expo-google-fonts/cairo": "^0.2.3",
"@hashiprobr/expo-pdf-reader": "^1.0.8",
"@react-native-async-storage/async-storage": "1.17.11",
"@react-native-community/datetimepicker": "6.7.3",
"@react-native-community/netinfo": "9.3.7",
"@react-native-masked-view/masked-view": "0.2.8",
"@react-navigation/drawer": "^6.6.2",
"@react-navigation/native": "^6.1.6",
"@react-navigation/stack": "^6.3.16",
"@types/react": "~18.0.27",
"apisauce": "^3.0.0",
"expo": "~48.0.18",
"expo-asset": "~8.9.1",
"expo-auth-session": "~4.0.3",
"expo-av": "~13.2.1",
"expo-blur": "~12.2.2",
"expo-calendar": "~11.1.1",
"expo-camera": "~13.2.1",
"expo-constants": "~14.2.1",
"expo-dev-client": "~2.2.1",
"expo-device": "~5.2.1",
"expo-image-picker": "~14.1.1",
"expo-intent-launcher": "~10.5.2",
"expo-linear-gradient": "~12.1.2",
"expo-linking": "~4.0.1",
"expo-location": "~15.1.1",
"expo-network": "~5.2.1",
"expo-notifications": "~0.18.1",
"expo-print": "~12.2.1",
"expo-random": "~13.1.1",
"expo-secure-store": "~12.1.1",
"expo-sharing": "~11.2.2",
"expo-sms": "~11.2.1",
"expo-splash-screen": "~0.18.2",
"expo-sqlite": "~11.1.1",
"expo-status-bar": "~1.4.4",
"expo-task-manager": "~11.1.1",
"expo-web-browser": "~12.1.1",
"fbjs": "^3.0.5",
"formik": "^2.4.0",
"jwt-decode": "^3.1.2",
"jwt-encode": "^1.0.1",
"lottie-react-native": "5.1.4",
"moment": "^2.29.4",
"react": "18.2.0",
"react-native": "0.71.8",
"react-native-3dcube-navigation": "^1.0.5",
"react-native-action-button": "^2.8.5",
"react-native-add-calendar-event": "^4.2.0",
"react-native-ble-plx": "^2.0.3",
"react-native-blob-util": "^0.18.2",
"react-native-collapsible": "^1.6.1",
"react-native-easy-toast": "^2.3.0",
"react-native-expo-image-cache": "^4.1.0",
"react-native-gesture-handler": "~2.9.0",
"react-native-linear-gradient": "^2.6.2",
"react-native-modal": "^13.0.1",
"react-native-modal-datetime-picker": "^15.0.1",
"react-native-modalbox": "^2.0.2",
"react-native-modalize": "^2.1.1",
"react-native-pager-view": "6.1.2",
"react-native-paper": "^5.8.0",
"react-native-pdf": "^6.6.2",
"react-native-progress": "^5.0.0",
"react-native-reanimated": "~2.14.4",
"react-native-redash": "^18.1.0",
"react-native-safe-area-context": "4.5.0",
"react-native-skeleton-placeholder": "^5.2.4",
"react-native-stopwatch-timer": "^0.0.21",
"react-native-svg": "13.4.0",
"react-native-swipe-gestures": "^1.0.5",
"react-native-tab-view": "^3.5.1",
"react-native-webview": "11.26.0",
"react-native-zebra-bluetooth-printer": "^1.0.12",
"realm": "^11.10.1",
"rn-pdf-reader-js": "^4.1.1",
"typescript": "^4.9.4",
"yup": "^1.2.0"
},
It seems that the package is incompatible with my dependencies
"react": "18.2.0",
"react-native": "0.71.8",
Can you update the package to be compatible with my project?

@wesvh
Copy link

wesvh commented Nov 27, 2023

You got it?

@syahbes
Copy link

syahbes commented Dec 13, 2023

same here.. could not made this work on my react native expo app
even when I tried to use
$npm run prebuild
or add d.ts file

@wesvh
Copy link

wesvh commented Dec 14, 2023

I build this package (use other github repository base, but integrate this funcionality)
https://www.npmjs.com/package/react-native-bluetooth-zebra-printer-qv

Only need follow this tutorial (only the android package own, because i fix the library for prevent edit in the node_modules)
https://www.youtube.com/watch?v=BXbseqogkMQ

@syahbes
Copy link

syahbes commented Dec 15, 2023

I build this package (use other github repository base, but integrate this funcionality) https://www.npmjs.com/package/react-native-bluetooth-zebra-printer-qv

Only need follow this tutorial (only the android package own, because i fix the library for prevent edit in the node_modules) https://www.youtube.com/watch?v=BXbseqogkMQ

Thank you!
I followed the tutorial and now I can see the printer via the Bluetooth manager

I also installed :
npm i react-native-bluetooth-zebra-printer-qv

and now how to print to my Zebra printer?
need to print simple text like a 'hello world'

I added a zpl for exemple
test_label.zpl.txt

@wesvh
Copy link

wesvh commented Dec 15, 2023

In my research to also make my zebra work, I discovered that there are multiple models of thermal printers, and some are configured as CPL and not as ZPL, for this the zebra have an app in the playstore called printer setup, there you link your bluetooth printer and in the configuration section you should do something like "print language" or something like that

@syahbes
Copy link

syahbes commented Dec 15, 2023

Thank you for the fast reply!
yes you are right the file can be zpl or cpl
but how to send it to the printer?

@wesvh
Copy link

wesvh commented Dec 15, 2023

I'm just active right now xd

It's simple, you just use the same method that is in this repository
RNZebraBluetoothPrinter.print(deviceAddress,zpl).then((res) => {
//do something with res
})

The only difference is that you will extract the RNZebraBluetoothPrinter method

From react-native-bluetooth-zebra-printer-qv

like that
import { RNZebraBluetoothPrinter } from "react-native-bluetooth-zebra-printer-qv";

And you pass it the deviceAddress, which you get (Do not link it from the BluetoothManager of the tutorial, just extract the macAddress, and pass it as a property to the function)

image

@syahbes
Copy link

syahbes commented Dec 15, 2023

Thank you!! I will try that

@syahbes
Copy link

syahbes commented Dec 15, 2023

Lifesaver! Your youtube video + npm library got me printing to my Zebra zd230 from RN Expo.
THANKS !

@syahbes
Copy link

syahbes commented Mar 3, 2024

Hi :)
I worked well for the past months but now when I tried to run the app got this error:

 ERROR  TypeError: Cannot set property 'DIRECTION' of null, js engine: hermes

do you know how I can solve it?

this is from the index.js in node_moduls/react-native-zebbra-printer-qv

import { NativeModules } from "react-native";
const {
 BluetoothManager,
 BluetoothEscposPrinter,
 BluetoothTscPrinter,
 RNZebraBluetoothPrinter,
} = NativeModules;

BluetoothTscPrinter.DIRECTION = {
 FORWARD: 0,
 BACKWARD: 1,
};

@syahbes
Copy link

syahbes commented Mar 20, 2024

Hi :) I worked well for the past months but now when I tried to run the app got this error:

 ERROR  TypeError: Cannot set property 'DIRECTION' of null, js engine: hermes

do you know how I can solve it?

this is from the index.js in node_moduls/react-native-zebbra-printer-qv

import { NativeModules } from "react-native";
const {
 BluetoothManager,
 BluetoothEscposPrinter,
 BluetoothTscPrinter,
 RNZebraBluetoothPrinter,
} = NativeModules;

BluetoothTscPrinter.DIRECTION = {
 FORWARD: 0,
 BACKWARD: 1,
};

Fixed..
The error occurred because I tried running it in the Expo Go app instead of the dev build on my mobile.

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

No branches or pull requests

3 participants