0.2.4 • Published 1 year ago

react-native-broadcast-receiver v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-broadcast-receiver

Native module for harware based scanners

Installation

npm install react-native-broadcast-receiver

Usage

1. Listen to broadcast events

import { BroadcastReceiver } from 'react-native-broadcast-receiver';

React.useEffect(() => {
  const sub = BroadcastReceiver.addEventListner((d) =>
    setScanned((x) => [...x, d.data])
  );
  return () => sub.remove();
}, []);

2. Listen to broadcast events (with custom intent actions and extraDataKey)

import { BroadcastReceiver } from 'react-native-broadcast-receiver';

BroadcastReceiver.setIntentActionConfig([
  { action: 'com.zzzz.yyyy.action', datakey: '<data_key>' },
]);

React.useEffect(() => {
  const sub = BroadcastReceiver.addEventListner((d) =>
    setScanned((x) => [...x, d.data])
  );
  return () => sub.remove();
}, []);

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library