0.1.6 • Published 7 months ago

react-native-handle-broadcast v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

react-native-broadcast-receiver

Native module for handle android broadcast

Installation

npm install react-native-handle-broadcast

Usage

1. Configure AndroidManifest.xml

<receiver android:name="com.handlebroadcast.BroadcastReceiverReceiver" android:enabled="true" android:exported="true">
  <intent-filter android:priority="1000">
    <action android:name="com.zzzz.yyyy.action" />
    <category android:name="android.intent.category.DEFAULT"></category>
  </intent-filter>
</receiver>

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

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

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

React.useEffect(() => {
  const sub = BroadcastReceiver.addEventListener((data) =>
    console.log(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

0.1.6

7 months ago

0.1.5

7 months ago

0.1.4

9 months ago

0.1.3

9 months ago

0.1.2

9 months ago

0.1.1

9 months ago