module config broadcast notification for android and NSNotification for IOS
npm install react-native-rodney-broadcast
or
yarn add react-native-rodney-broadcast
import React, { useEffect, useState } from 'react';
import { DeviceEventEmitter } from 'react-native';
import RodneyBroadcast from 'react-native-rodney-broadcast';
// ...
const [result, setResult] = useState()
const eventEmitter = new NativeEventEmitter(NativeModules.RodneyBroadcast);
RodneyBroadcast.addName(eventName);
const registerId = await RodneyBroadcast.register('NAME OF INTENTE FILTER','NAME OF PUT EXTRA','NAME OF SERVICE');
eventEmitter.addListener('NAME OF SERVICE', function (map) {
setResult(map.data)
});
// ...
await eventEmitter.unregister(registerId);
import React from 'react';
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native';
import { createServiceRodneyBroadcast } from 'react-native-rodney-broadcast';
const [
RodneyBroadcastProvider,
useRodneyBroadcast,
] = createServiceRodneyBroadcast(
'app.dsic.barcodetray.BARCODE_BR_DECODING_DATA',
['EXTRA_BARCODE_DECODED_DATA'],
'RODNEY'
);
function Home() {
const { data, clear } = useRodneyBroadcast();
return (
<View style={styles.container}>
<Text>{data?.EXTRA_BARCODE_DECODED_DATA || 'Aguardando Leitura'}</Text>
<TouchableOpacity onPress={clear}>
<Text>CLear Data</Text>
</TouchableOpacity>
</View>
);
}
export default function App() {
return (
<RodneyBroadcastProvider>
<Home />
</RodneyBroadcastProvider>
);
}
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT