react-native-mendix-receiver
Version:
Receiver bridge for Mendix Native Widgets using React Native
37 lines (28 loc) • 991 B
JavaScript
import { NativeModules, DeviceEventEmitter } from "react-native";
const { RNZebraBarcode } = NativeModules;
export class ZebraBarcode {
constructor() {
if (RNZebraBarcode != null) {
// Optional: initialize anything if needed
}
}
listenerBarcode(intentAction, dataStringExtra, listener) {
// Start Broadcast Receiver
const extra = (typeof dataStringExtra === "string" && dataStringExtra.length > 0)
? dataStringExtra
: null;
RNZebraBarcode.startUp(intentAction, extra);
// Create Listener for Mendix
const onSessionConnect = event => {
listener(event["BarcodeValue"]);
};
const subscription = DeviceEventEmitter.addListener("BarcodeReceived", onSessionConnect);
return subscription;
}
hideNavigationBar() {
RNZebraBarcode.hideNavigationBar();
}
showNavigationBar() {
RNZebraBarcode.showNavigationBar();
}
}