react-native-ios-shareplay
TypeScript icon, indicating that this package has built-in type declarations

0.3.5 • Public • Published

react-native-ios-shareplay

iOS 15 share play API in react-native

Installation

yarn add react-native-ios-shareplay

And go to Xcode Capabilities and enable "Group Activities"

Example

Usage

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 to learn how to contribute to the repository and the development workflow.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i react-native-ios-shareplay

Weekly Downloads

1

Version

0.3.5

License

MIT

Unpacked Size

31.8 kB

Total Files

27

Last publish

Collaborators

  • zhigang1992