# react-native-nsd

> React Native module that provides access to Android's Network Service Discovery.

Latest version **0.0.4** (published 2018-12-29) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install react-native-nsd
pnpm add react-native-nsd
yarn add react-native-nsd
bun add react-native-nsd
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2018-12-29 |
| First published | 2018-10-25 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Nicolás Echániz |
| Maintainers | nicoechaniz |
| Keywords | react-native, nsd, network service discovery |

## Links

- npm: https://www.npmjs.com/package/react-native-nsd
- Repository: https://github.com/AlterMundi/react-native-nsd
- Homepage: https://github.com/AlterMundi/react-native-nsd#readme
- Issues: https://github.com/AlterMundi/react-native-nsd/issues
- npm.io page: https://npm.io/package/react-native-nsd

## Recent versions

- 0.0.4 (latest) — 2018-12-29
- 0.0.3 — 2018-11-28
- 0.0.2 — 2018-11-21
- 0.0.1 — 2018-10-25

## README

# react-native-nsd

This module is a wrapper to use Android's Network Service Discovery from a react-native App.

## Getting started

`$ npm install react-native-nsd --save`

### Mostly automatic installation

`$ react-native link react-native-nsd`

### Manual installation

#### Android

1. Open up `android/app/src/main/java/[...]/MainActivity.java`

- Add `import net.altermundi.rn_nsd.NsdPackage;` to the imports at the top of the file
- Add `new NsdPackage()` to the list returned by the `getPackages()` method

2. Append the following lines to `android/settings.gradle`:
   ```
   include ':react-native-nsd'
   project(':react-native-nsd').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-sd/android')
   ```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
   ```
     compile project(':react-native-nsd')
   ```

## Usage

To use the module in your App.

```javascript
import { NSD } from "react-native-nsd";
import { DeviceEventEmitter } from "react-native";

// Listen and react to discovered/resolved services
DeviceEventEmitter.addListener("serviceResolved", function(e) {
  console.log("JS: service resolved");
  console.log(e.name, e.host, e.port);
  // if you are using react-native-handshake you can receive handshake message from the discovered peer
  // You would import { Handshake } from react-native-handshake first and then you can do
  Handshake.receiveKey(e.host, e.port);
  // read react-native-handshake documentation for info on how to use it
});

// NSD methods (self explanatory)
NSD.setServiceName("myservice");
NSD.discover();
NSD.stopDiscovery();
NSD.register(port_number);
NSD.unregister();
```

---
_Source: https://npm.io/package/react-native-nsd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
