# react-native-ios-shareplay

> iOS 15 share play API in RN

Latest version **0.3.5** (published 2021-10-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-ios-shareplay
pnpm add react-native-ios-shareplay
yarn add react-native-ios-shareplay
bun add react-native-ios-shareplay
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.5 |
| Published | 2021-10-03 |
| First published | 2021-09-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 31 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | Kyle Fang |
| Maintainers | zhigang1992 |
| Keywords | react-native, ios |

## Links

- npm: https://www.npmjs.com/package/react-native-ios-shareplay
- Repository: https://github.com/zhigang1992/react-native-share-play
- Homepage: https://github.com/zhigang1992/react-native-share-play#readme
- Issues: https://github.com/zhigang1992/react-native-share-play/issues
- npm.io page: https://npm.io/package/react-native-ios-shareplay

## Recent versions

- 0.3.5 (latest) — 2021-10-03
- 0.3.4 — 2021-10-02
- 0.3.3 — 2021-10-02
- 0.3.2 — 2021-10-02
- 0.3.1 — 2021-10-01
- 0.3.0 — 2021-10-01
- 0.2.0 — 2021-09-13

## README

# react-native-ios-shareplay

iOS 15 share play API in react-native

## Installation

```sh
yarn add react-native-ios-shareplay
```

And go to Xcode Capabilities and enable "Group Activities"

## Example
<video src='https://user-images.githubusercontent.com/1057756/135738117-349cbd3e-5e80-48cf-a1cc-40ab4df027e0.mp4' width=280></video>

## Usage

```js
import SharePlay from 'react-native-ios-shareplay';

// initialize

if (await SharePlay.isSharePlayAvailable()) {
  if ((await SharePlay.getInitialSession()) != null) {
    SharePlay.joinSession();
  }
}

// event
const newSessionEm = SharePlayEvent.addListener('newSession', (info) => {
  // get ready
  SharePlay.joinSession();
});

const newSessionEm = SharePlayEvent.addListener('newActivity', (info) => {
  // process activity
});

const newMessage = SharePlayEvent.addListener('receivedMessage', (info) => {
  // process message
});

// start activity
await SharePlay.startActivity(`Test Message: ${Math.random()}`, {
  extraInfo: JSON.stringify(payload),
  fallbackURL: 'https://fallback.url.that.will.open.on.desktop',
  prepareFirst: false,
}).catch((e) => Alert.alert(e.message));

// post message
await SharePlay.sendMessage(`Test Message: ${Math.random()}`).catch((e) =>
  Alert.alert(e.message)
);
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

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