0.6.1 • Published 5 months ago
react-native-broadcast-receiver v0.6.1
react-native-broadcast-receiver
:sparkles: :rocket: Supports React-Native Bridgeless mode
This package allows you to register custom intent to listen in react native applications. The idea here is to reduce the number app builds that are required if you change the native code in react native. With this you can inject custom intent config at runtime.
Installation
npm
npm install react-native-broadcast-receiver
yarn
yarn add react-native-broadcast-receiver
Usage
Listen to broadcast events with custom intent actions and extraDataKey
import { BroadcastReceiver } from 'react-native-broadcast-receiver';
BroadcastReceiver.setIntentActionConfig([
{ action: 'com.zzzz.yyyy.action1', datakey: '<data_key1>' },
{ action: 'com.zzzz.yyyy.action2', datakey: '<data_key2>' },
{ action: 'com.zzzz.yyyy.action3', datakey: '' }, // For empty dataKey an object will be returned instead of a string
]);
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