
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
react-native-opentok
Advanced tools
React Native OpenTok is wrapper over native TokBox OpenTok SDK. The OpenTok platform, developed by TokBox, makes it easy to embed high-quality interactive video, voice, messaging, and screen sharing into web and mobile apps. OpenTok uses WebRTC for audio-video communications 👀🎧. For more info on how OpenTok works, check out OpenTok Basics.
react-native
>=0.49.3Supported OpenTok SDK version:
OpenTok SDK
2.11.+React native OpenTok SDK depends on native OpenTok SDK implementations. You need to integrate OpenTok SDK into your existing application. Following steps needs to be done in order to have library working correctly:
Add library using yarn
📦 (or npm
):
yarn add react-native-opentok
ios/
directory please run pod init
.Podfile
with:source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target '<YOUR_PROJECT_NAME>' do
node_modules_path = '../node_modules'
pod 'yoga', path: "#{node_modules_path}/react-native/ReactCommon/yoga/yoga.podspec"
pod 'React', path: "#{node_modules_path}/react-native"
pod 'RNOpenTok', path: "#{node_modules_path}/react-native-opentok/ios"
end
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "React"
target.remove_from_project
end
end
end
pod install
.OPENTOK_API_KEY
key to your Info.plist
:<key>OPENTOK_API_KEY</key>
<string>YOUR_API_KEY</string>
<key>NSCameraUsageDescription</key>
<string>${PRODUCT_NAME} Camera Usage</string>
<key>NSMicrophoneUsageDescription</key>
<string>${PRODUCT_NAME} Microphone Usage</string>
react-native link
.android/build.gradle
file and update allprojects section:allprojects {
repositories {
...
maven {
url "http://tokbox.bintray.com/maven"
}
}
}
OPENTOK_API_KEY
to your AndroidManifest.xml
(within <application>
tag):<meta-data android:name="OPENTOK_API_KEY" android:value="YOUR_OPENTOK_API_KEY" />
Connects to choosen session.
const connectToSession = async () => {
try {
await OpenTok.connect('YOUR_SESSION_ID', 'YOUR_TOKEN');
} catch (e) {
console.log(e)
}
}
Disconnects from chosen session.
OpenTok.disconnect('YOUR_SESSION_ID');
Disconnects all available sessions.
OpenTok.disconnectAll();
Send signal to chosen session.
const connectToSession = async () => {
try {
await OpenTok.connect('YOUR_SESSION_ID', 'YOUR_TOKEN');
} catch (e) {
console.log(e)
}
}
Constants for events thrown in app. Available values:
Event listener, for events listed above.
OpenTok.on(OpenTok.events.ON_SIGNAL_RECEIVED, e => console.log(e));
Removes listener.
OpenTok.removeListener(OpenTok.events.ON_SIGNAL_RECEIVED);
Component used for publishing the video to the stream.
Available props:
sessionId: string
- ID of the session (you need to connect it before using this component).onPublishStart?: Function
- Invoked when publishing starts. Optional.onPublishStop?: () => void
- Invoked when publishing stops. Optional.onPublishError?: () => void
- Invoked when publish error occurs. Optional.mute?
: Boolean - This props tells Publisher if should publish audio as well or not. Optional. Defaults to false.video?
: Boolean - This props tells Publisher if should publish video as well or not. Optional. Defaults to true.Available methods:
switchCamera()
: switches to the next camera. Goes back to first one when out of cameras.import { Publisher } from 'react-native-opentok'
<Publisher
style={{ height: 100, width: 200 }}
sessionId={sessionId}
onPublishStart={() => { console.log('started')}}
/>
Component used for subscribing to the stream.
Available props:
sessionId: string
- ID of the session (you need to connect it before using this component).onSubscribeStart?: Function
- Invoked when stream starts. Optional.onSubscribeStop?: () => void
- Invoked when stream stops. Optional.onSubscribeError?: () => void
- Invoked when subscribing error occurs. Optional.mute?
: Boolean - This props tells Subscriber if should subscribe audio as well or not. Optional. Defaults to false.video?
: Boolean - This props tells Subscriber if should subscribe video as well or not. Optional. Defaults to true.import { Subscriber } from 'react-native-opentok'
<Subscriber
style={{ height: 100, width: 200 }}
sessionId={sessionId}
onSubscribeStart={() => { console.log('started')}}
/>
Simply import the library and use methods/components listed above.
import OpenTok from 'react-native-opentok';
Check out example project.
![]() Michał Chudziak 💻 | ![]() Piotr Drapich 💻 | ![]() Mike Grabowski 💻 | Jakub Beneš 💻 |
---|
Thanks to TokBox for native SDKs development.
FAQs
React Native OpenTok
The npm package react-native-opentok receives a total of 6 weekly downloads. As such, react-native-opentok popularity was classified as not popular.
We found that react-native-opentok demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.