README
react-native-bonjour
Basic Bonjour implementation for React-native
This repo has been moved to another naming to be non OSX-specific.
Install
npm i -S react-native-bonjour
- Right click on the
Libraries
folder in XCode, and addRNBonjour.xcodeproj
- Go to your Build Phases, under Link Binary with Libraries, add
libRNBonjour.a
- Click on the
RNBonjour.xcodeproj
in theLibraries
folder, search Header Search Paths and add$(SRCROOT)/../../react-native/React
if it's not.
API
import Bonjour from 'react-native-bonjour';
const bonjour = new Bonjour();
Methods
Start the bonjour scan scan(type = 'http', protocol = 'tcp', domain = 'local.')
This will initialize the scan from the Bonjour
instance. Will stop another scan if any is running.
Stop the scan stop()
If any scan is running, stop it. Otherwise do nothing.
Returns resolved services getServices()
Will return all names of services that have been resolved.
Events
bonjour.on('start', () => { console.log('The scan has started.'); });
Triggered on scan start start
Triggered on scan stop stop
Triggered when a service is found found
Broadcast the service name.
Triggered when a service is removed remove
Broadcast the service name.
Triggered either when a service is found or removed update
Triggered when an error occurs error
Webpack
This component uses ES6. If using webpack you should launch babel
on the Bonjour.js
file.