Skip to content

k7k0/react-native-opentok

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-opentok

React Native SDK for OpenTok platform.

Installation

Requirements

  • RN >= 0.29.0

iOS

To install using Cocoapods, simply insert the following line into your Podfile and run pod install

pod 'react-native-opentok', :path => '../node_modules/react-native-opentok'

Android

  • In your android/app/build.gradle add:
...
dependencies {
  ...
  compile project(':react-native-opentok')
  compile 'com.opentok.android:opentok-android-sdk:2.8.+'
}
  • In your android/settings.gradle add:
...
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/android')
  • In your application object, add:
import io.callstack.react.opentok.MainPackage;
...

    @Override protected List<ReactPackage> getPackages() {
      return Arrays.asList(
          ...
          new MainPackage()
        );
    }

Props

Prop Type
apiKey string
sessionId string
token string
------------ -------------
spinnerContainerStyle object
------------ -------------
onPublishStart function
onPublishError function
onPublishStop function
onSessionDidConnect function
onSessionDidDisconnect function
onArchiveStarted function
onArchiveStopped function
------------ -------------
onSubscribeStart function
onSubscribeError function
onSubscribeStop function

Basic usage

Publisher

import { PublisherView } from 'react-native-opentok';

export default function Publisher() {
  return (
    <PublisherView
      apiKey={OPENTOK_API_KEY}
      sessionId={OPENTOK_SESSION_ID}
      token={OPENTOK_PUBLISHER_TOKEN}
      style={{ width: 300, height: 200 }}
    />
  );
}

Subscriber

import { SubscriberView } from 'react-native-opentok';

export default function Subscriber() {
  return (
    <SubscriberView
      apiKey={OPENTOK_API_KEY}
      sessionId={OPENTOK_SESSION_ID}
      token={OPENTOK_SUBSCRIBER_TOKEN}
      style={{ width: 300, height: 200 }}
    />
  );
}

Signaling

import { Session } from 'react-native-opentok';

Session.connect(OPENTOK_API_KEY, SESSION_ID, PUBLISHER_TOKEN || SUBSCRIBER_TOKEN);
Session.onMessageRecieved((e) => console.log(e));
Session.sendMessage('message');

Running example project

$ cd examples/Basic && npm i && npm start

callstack.io

About

React Native OpenTok

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 76.8%
  • Java 13.3%
  • JavaScript 9.0%
  • Ruby 0.9%