iOS 15 share play API in react-native

Overview

react-native-shareplay

iOS 15 share play API in react-native

Installation

yarn add react-native-shareplay

And go to Xcode Capabilities and enable "Group Activities"

Example

telegram-cloud-document-1-5100626177735786886.mp4

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

You might also like...
React Native Template for Taro

React Native Template for Taro requirement taro: @tarojs/cli@^3.2.0 framework: 'react' quick start install react native library install peerDependenci

A suite of IoT tools to use with React Native.

react-native-iot-tools WIP. A suite of IoT tools for React Native applications. Package iOS Android @react-native-iot-tools/bluetooth ✅ ❌ @react-nativ

A testing MQTT react native library

react-native-awesome-testing abc Installation npm install react-native-awesome-testing Usage import { multiply } from "react-native-awesome-testing";

Encryption/Decryption for React Native

@dhairyasharma/react-native-encryption Encryption/decryption for React Native. Benchmark File Details File Link http://bit.do/benchmarkfile File Size

Encryption/Decryption for React Native

@dhairyasharma/react-native-encryption Encryption/decryption for React Native. Benchmark File Details File Link http://bit.do/benchmarkfile File Size

React Native Photo Editor (RNPE)
React Native Photo Editor (RNPE)

React Native Photo Editor (RNPE) 🌄 Image editor using native modules for iOS an

Discover Movies and TV shows -  React Native
Discover Movies and TV shows - React Native

movieapp Discover Movies and TV shows Download APK file Download from Google Drive - v2.2.1 What's included Name Description React Native Build Native

All my React Native examples

ReactNativeExamples All my React Native examples and experiements can be found here. This repo is divided into two sub folders, Instructions git clone

React Native Twitch application
React Native Twitch application

Notes I'm going to rewrite this project 😉 . Be ready to new Twitch application. Twitch This project was built for The Rolling Scopes #18 meetup. As o

Comments
  • Release build

    Release build

    Hello,

    Thanks a lot for the project! It compiles and works well in Debug configuration. But as soon as I switch to Release configuration I have the following errors:

    node_modules/react-native-shareplay/ios/SharePlay.swift:21:19: Cannot find type 'GroupActivityMetadata' in scope
    node_modules/react-native-shareplay/ios/SharePlay.swift:12:30: Cannot find type 'GroupActivity' in scope
    node_modules/react-native-shareplay/ios/SharePlay.swift:55:30: Cannot find 'GroupStateObserver' in scope
    node_modules/react-native-shareplay/ios/SharePlay.swift:78:23: Cannot find type 'GroupSession' in scope
    node_modules/react-native-shareplay/ios/SharePlay.swift:79:20: Cannot find type 'GroupSessionMessenger' in scope
    node_modules/react-native-shareplay/ios/SharePlay.swift:98:31: Cannot find type 'GroupSession' in scope
    node_modules/react-native-shareplay/ios/SharePlay.swift:22:24: Cannot find 'GroupActivityMetadata' in scope
    node_modules/react-native-shareplay/ios/SharePlay.swift:24:26: Cannot infer contextual base in reference to member 'generic'
    node_modules/react-native-shareplay/ios/SharePlay.swift:64:55: Type 'GenericGroupActivity' has no member 'sessions'
    node_modules/react-native-shareplay/ios/SharePlay.swift:82:29: 'nil' requires a contextual type
    node_modules/react-native-shareplay/ios/SharePlay.swift:83:26: 'nil' requires a contextual type
    node_modules/react-native-shareplay/ios/SharePlay.swift:89:31: Type of expression is ambiguous without more context
    node_modules/react-native-shareplay/ios/SharePlay.swift:101:25: Cannot find 'GroupSessionMessenger' in scope
    node_modules/react-native-shareplay/ios/SharePlay.swift:103:45: Unable to infer type of a closure parameter 'state' in the current context
    node_modules/react-native-shareplay/ios/SharePlay.swift:110:49: Unable to infer type of a closure parameter 'activity' in the current context
    node_modules/react-native-shareplay/ios/SharePlay.swift:115:49: Tuple pattern cannot match values of non-tuple type '_'
    node_modules/react-native-shareplay/ios/SharePlay.swift:138:31: Type of expression is ambiguous without more context
    node_modules/react-native-shareplay/ios/SharePlay.swift:143:59: Value of type 'GenericGroupActivity' has no member 'prepareForActivation'
    node_modules/react-native-shareplay/ios/SharePlay.swift:144:40: Value of type 'GenericGroupActivity' has no member 'activate'
    node_modules/react-native-shareplay/ios/SharePlay.swift:148:32: Value of type 'GenericGroupActivity' has no member 'activate'
    node_modules/react-native-shareplay/ios/SharePlay.swift:152:31: Type of expression is ambiguous without more context
    node_modules/react-native-shareplay/ios/SharePlay.swift:158:28: Type of expression is ambiguous without more context
    node_modules/react-native-shareplay/ios/SharePlay.swift:164:31: Type of expression is ambiguous without more context
    node_modules/react-native-shareplay/ios/SharePlay.swift:170:31: Type of expression is ambiguous without more context
    

    It looks like it cannot find the GroupActivity framework.

    I am on XCode 13.1. My app entitlements contain the Group Activities capability (com.apple.developer.group-session).

    Have you built a project in Release configuration with your module? Have you made any additional steps?

    opened by Minishlink 10
  • isSharePlayAvailable always return false

    isSharePlayAvailable always return false

    I was trying to implement this library and also added group activity capability in Xcode but still I am getting false as response from isSharePlayAvailable method. Is there any native code I have to add to make this work?

    opened by Tusha-ar 1
  • feat: Add sessionWaiting/sessionJoined events

    feat: Add sessionWaiting/sessionJoined events

    Can be useful for loading info or redirecting to the actual activity only when we're sure the user has joined the session (as SharePlay.join() is not a promise)

    newSession.activity.eventPayload is added as body in order to prevent mixing up with other potential sessions

    opened by Minishlink 0
  • Bump minimal iOS deployment target to fix Release build

    Bump minimal iOS deployment target to fix Release build

    • Necessary to make it work on old RN versions (tested on 0.64)
    • You might need to do this in your project when bumping iOS deployment target (unrelated to this lib)
    • In this repo's example it doesn't compile yet but this is not related
    • Fixes #2
    opened by Minishlink 0
Releases(v0.9.0)
Owner
Popshop Live
Popshop Live
React Native library that implements PayPal Checkout flow using purely native code (swift).

react-native-paypal-swift React Native library that implements PayPal Checkout flow using purely native code (swift). Installation npm install react-n

Tibb 6 Nov 28, 2022
iOS's Stocks App clone written in React Native for demo purpose (available both iOS and Android).

FinanceReactNative iOS's Stocks App clone written in React Native for demo purpose (available both iOS and Android). Data is pulled from Yahoo Finance

kf 2k Dec 29, 2022
🏀 iOS and Android NBA app created with React Native

Swish An iOS and Android NBA app created with React Native. If you would like to request a feature, find a bug, have a question, or would like to leav

James Kuczmarski 108 Nov 11, 2022
Blazing⚡️Fast BTC and ETH Wallet Generator library for React Native, Android and iOS

Blazing ⚡️ Fast BTC and ETH Wallet Generator library for React Native, Android and iOS.

Coingrig 3 Feb 21, 2022
React Native utility library around image and video files for getting metadata like MIME type, timestamp, duration, and dimensions. Works on iOS and Android using Java and Obj-C, instead of Node 🚀.

Qeepsake React Native File Utils Extracts information from image and video files including MIME type, duration (video), dimensions, and timestamp. The

Qeepsake 12 Oct 19, 2022
POC for a bug with react-native-webview crashing on IOS 16.1

POC Shared Worker issues with IOS 16.1 webview Apple Developers post with workaround Webkit confirmed issue Start a simple http server with shared wor

Mauri de Souza Meneguzzo 2 Oct 31, 2022
A react native interface for integrating payments using Braintree

A react native interface for integrating payments using Braintree

eKreative 17 Dec 30, 2022
React Native 实现无侵入自定义下拉刷新组件

react-native-ly-refresh-control 下拉刷新 iOS 基于MJRefresh 通过RCTCustomRefreshContolProtocol实现RefreshControl组件封装 JS端可以无侵入自定义下拉刷新只需要替换对应的refreshControl Androi

少言 12 Jul 2, 2022
React Native package for interacting with HomeKit devices

React Native package for interacting with HomeKit devices

Ibrahim Berat Kaya 4 Dec 24, 2021
react native esptouch

react-native-esptouch One should know that This is a Unofficial project. The official demo is below: EsptouchForAndroid EsptouchForIOS Getting started

五毛共和国 Wumaoland 0 Oct 25, 2021