0.9.0 • Published 3 years ago

react-native-shareplay v0.9.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-native-shareplay

iOS 15 share play API in react-native

Installation

yarn add react-native-shareplay
  • Go to Xcode Capabilities and enable "Group Activities"
  • Make sure your iOS Deployment target is 11.0 (IPHONEOS_DEPLOYMENT_TARGET in project.pbxproj and platform :ios, '11.0' in your Podfile)

Example

Usage

import SharePlay from 'react-native-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

0.9.0

3 years ago

0.8.0

3 years ago

0.7.0

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.6

3 years ago

0.0.1

3 years ago