Installations
npm install react-native-twilio-video-webrtc-pru
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
12.18.0
NPM Version
6.14.4
Score
67.7
Supply Chain
99
Quality
74.6
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
Java (50.25%)
JavaScript (23.84%)
Objective-C (22.25%)
TypeScript (1.85%)
Starlark (1.06%)
Ruby (0.76%)
Developer
Download Statistics
Total Downloads
14,888
Last Day
1
Last Week
1
Last Month
10
Last Year
1,010
GitHub Statistics
610 Stars
304 Commits
403 Forks
25 Watching
14 Branches
70 Contributors
Package Meta Information
Latest Version
1.0.3
Package Id
react-native-twilio-video-webrtc-pru@1.0.3
Unpacked Size
578.45 kB
Size
211.79 kB
File Count
89
NPM Version
6.14.4
Node Version
12.18.0
Total Downloads
Cumulative downloads
Total Downloads
14,888
Last day
0%
1
Compared to previous day
Last week
-80%
1
Compared to previous week
Last month
25%
10
Compared to previous month
Last year
18.7%
1,010
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Twilio Video (WebRTC) for React Native
Platforms:
- iOS
- Android
People using a version < 1.0.1 please move to 1.0.1 since the project changed a lot internally to support the stable TwilioVideo version.
Installation
- react-native >= 0.40.0: install react-native-twilio-video-webrtc@1.0.1
- react-native < 0.40.0: install react-native-twilio-video-webrtc@1.0.0
Install Node Package
Option A: yarn
1yarn add https://github.com/blackuy/react-native-twilio-video-webrtc
Option B: npm
1npm install https://github.com/blackuy/react-native-twilio-video-webrtc --save
iOS
Option A: Install with CocoaPods (recommended)
- Add this package to your Podfile
1pod 'react-native-twilio-video-webrtc', path: '../node_modules/react-native-twilio-video-webrtc'
Note that this will automatically pull in the appropriate version of the underlying TwilioVideo
pod.
- Install Pods with
1pod install
Option B: Install without CocoaPods (manual approach)
- Add the Twilio dependency to your Podfile
1pod 'TwilioVideo'
- Install Pods with
1pod install
- Add the XCode project to your own XCode project's
Libraries
directory from
node_modules/react-native-twilio-video-webrtc/ios/RNTwilioVideoWebRTC.xcodeproj
-
Add
libRNTwilioVideoWebRTC.a
to your XCode project target'sLinked Frameworks and Libraries
-
Update
Build Settings
Find Search Paths
and add $(SRCROOT)/../node_modules/react-native-twilio-video-webrtc/ios
with recursive
to Framework Search Paths
and Library Search Paths
Post install
Be sure to increment your iOS Deployment Target to at least iOS 11 through XCode and your Podfile
contains
platform :ios, '11.0'
Permissions
To enable camera usage and microphone usage you will need to add the following entries to your Info.plist
file:
<key>NSCameraUsageDescription</key>
<string>Your message to user when the camera is accessed for the first time</string>
<key>NSMicrophoneUsageDescription</key>
<string>Your message to user when the microphone is accessed for the first time</string>
Known Issues
TwilioVideo version 1.3.8 (latest) has the following know issues.
- Participant disconnect event can take up to 120 seconds to occur. Issue 99
- AVPlayer audio content does not mix properly with Room audio. Issue 62
Android
As with iOS, make sure the package is installed:
1yarn add https://github.com/blackuy/react-native-twilio-video-webrtc
Then add the library to your settings.gradle
file:
include ':react-native-twilio-video-webrtc'
project(':react-native-twilio-video-webrtc').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-twilio-video-webrtc/android')
And include the library in your dependencies in android/app/build.gradle
:
dependencies {
.....
.....
.....
compile project(':react-native-twilio-video-webrtc')
}
You will also need to update this file so that you compile with java 8 features:
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
Now you're ready to load the package in MainApplication.java
. In the imports section, add this:
1import com.twiliorn.library.TwilioPackage;
Then update the getPackages()
method:
1 protected List<ReactPackage> getPackages() { 2 return Arrays.<ReactPackage>asList( 3 ... 4 new TwilioPackage() 5 ); 6 }
Permissions
For most applications, you'll want to add camera and audio permissions to your AndroidManifest.xml
file:
1 <uses-permission android:name="android.permission.CAMERA" /> 2 <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> 3 <uses-permission android:name="android.permission.RECORD_AUDIO" /> 4 <uses-feature android:name="android.hardware.camera" android:required="false" /> 5 <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> 6 <uses-feature android:name="android.hardware.microphone" android:required="false" />
Newer versions of Android have a different permissions model. You will need to use the PermissionsAndroid
class in react-native
in order to request the CAMERA
and RECORD_AUDIO
permissions.
Additional Tips
Under default settings, the Android build will fail if the total number of symbols exceeds a certain threshold. If you should encounter this issue when adding this library (e.g., if your build fails with com.android.dex.DexIndexOverflowException
), you can turn on jumbo mode by editing your app/build.gradle
:
android {
...
dexOptions {
jumboMode true
}
}
If you are using proguard (very likely), you will also need to ensure that the symbols needed by
this library are not stripped. To do that, add these two lines to proguard-rules.pro
:
-keep class org.webrtc.** { *; }
-keep class com.twilio.** { *; }
-keep class tvi.webrtc.** { *; }
Docs
You can see the documentation here.
Usage
We have three important components to understand:
1import { 2 TwilioVideo, 3 TwilioVideoLocalView, 4 TwilioVideoParticipantView 5} from 'react-native-twilio-video-webrtc'
TwilioVideo
/ is responsible for connecting to rooms, events delivery and camera/audio.TwilioVideoLocalView
/ is responsible local camera feed viewTwilioVideoParticipantView
/ is responsible remote peer's camera feed view
Here you can see a complete example of a simple application that uses almost all the apis:
1import React, { Component } from 'react'; 2import { 3 TwilioVideoLocalView, 4 TwilioVideoParticipantView, 5 TwilioVideo 6} from 'react-native-twilio-video-webrtc' 7 8export default class Example extends Component { 9 state = { 10 isAudioEnabled: true, 11 isVideoEnabled: true, 12 status: 'disconnected', 13 participants: new Map(), 14 videoTracks: new Map(), 15 token: '' 16 } 17 18 _onConnectButtonPress = () => { 19 this.refs.twilioVideo.connect({ accessToken: this.state.token }) 20 this.setState({status: 'connecting'}) 21 } 22 23 _onEndButtonPress = () => { 24 this.refs.twilioVideo.disconnect() 25 } 26 27 _onMuteButtonPress = () => { 28 this.refs.twilioVideo.setLocalAudioEnabled(!this.state.isAudioEnabled) 29 .then(isEnabled => this.setState({isAudioEnabled: isEnabled})) 30 } 31 32 _onFlipButtonPress = () => { 33 this.refs.twilioVideo.flipCamera() 34 } 35 36 _onRoomDidConnect = ({ roomName, error }) => { 37 console.log('onRoomDidConnect: ', roomName); 38 39 this.setState({ status: 'connected' }); 40 }; 41 42 _onRoomDidDisconnect = ({roomName, error}) => { 43 console.log("ERROR: ", error) 44 45 this.setState({status: 'disconnected'}) 46 } 47 48 _onRoomDidFailToConnect = (error) => { 49 console.log("ERROR: ", error) 50 51 this.setState({status: 'disconnected'}) 52 } 53 54 _onParticipantAddedVideoTrack = ({participant, track}) => { 55 console.log("onParticipantAddedVideoTrack: ", participant, track) 56 57 this.setState({ 58 videoTracks: new Map([ 59 ...this.state.videoTracks, 60 [track.trackSid, { participantSid: participant.sid, videoTrackSid: track.trackSid }] 61 ]), 62 }); 63 } 64 65 _onParticipantRemovedVideoTrack = ({participant, track}) => { 66 console.log("onParticipantRemovedVideoTrack: ", participant, track) 67 68 const videoTracks = this.state.videoTracks 69 videoTracks.delete(track.trackSid) 70 71 this.setState({videoTracks: { ...videoTracks }}) 72 } 73 74 render() { 75 return ( 76 <View style={styles.container}> 77 { 78 this.state.status === 'disconnected' && 79 <View> 80 <Text style={styles.welcome}> 81 React Native Twilio Video 82 </Text> 83 <TextInput 84 style={styles.input} 85 autoCapitalize='none' 86 value={this.state.token} 87 onChangeText={(text) => this.setState({token: text})}> 88 </TextInput> 89 <Button 90 title="Connect" 91 style={styles.button} 92 onPress={this._onConnectButtonPress}> 93 </Button> 94 </View> 95 } 96 97 { 98 (this.state.status === 'connected' || this.state.status === 'connecting') && 99 <View style={styles.callContainer}> 100 { 101 this.state.status === 'connected' && 102 <View style={styles.remoteGrid}> 103 { 104 Array.from(this.state.videoTracks, ([trackSid, trackIdentifier]) => { 105 return ( 106 <TwilioVideoParticipantView 107 style={styles.remoteVideo} 108 key={trackSid} 109 trackIdentifier={trackIdentifier} 110 /> 111 ) 112 }) 113 } 114 </View> 115 } 116 <View 117 style={styles.optionsContainer}> 118 <TouchableOpacity 119 style={styles.optionButton} 120 onPress={this._onEndButtonPress}> 121 <Text style={{fontSize: 12}}>End</Text> 122 </TouchableOpacity> 123 <TouchableOpacity 124 style={styles.optionButton} 125 onPress={this._onMuteButtonPress}> 126 <Text style={{fontSize: 12}}>{ this.state.isAudioEnabled ? "Mute" : "Unmute" }</Text> 127 </TouchableOpacity> 128 <TouchableOpacity 129 style={styles.optionButton} 130 onPress={this._onFlipButtonPress}> 131 <Text style={{fontSize: 12}}>Flip</Text> 132 </TouchableOpacity> 133 <TwilioVideoLocalView 134 enabled={true} 135 style={styles.localVideo} 136 /> 137 </View> 138 </View> 139 } 140 141 <TwilioVideo 142 ref="twilioVideo" 143 onRoomDidConnect={ this._onRoomDidConnect } 144 onRoomDidDisconnect={ this._onRoomDidDisconnect } 145 onRoomDidFailToConnect= { this._onRoomDidFailToConnect } 146 onParticipantAddedVideoTrack={ this._onParticipantAddedVideoTrack } 147 onParticipantRemovedVideoTrack= { this._onParticipantRemovedVideoTrack } 148 /> 149 </View> 150 ); 151 } 152} 153 154AppRegistry.registerComponent('Example', () => Example);
Run the Example Application
To run the example application:
- Move to the Example directory:
cd Example
- Install node dependencies:
yarn install
- Install objective-c dependencies:
cd ios && pod install
- Open the xcworkspace and run the app:
open Example.xcworkspace
Migrating from 1.x to 2.x
- Make sure your pod dependencies are updated. If you manually specified a pod version, you'll want to update it as follows:
s.dependency 'TwilioVideo', '~> 2.2.0'
-
Both participants and tracks are uniquely identified by their
sid
/trackSid
field. ThetrackId
field no longer exists and should be replaced bytrackSid
. Commensurate with this change, participant views now expectparticipantSid
andvideoTrackSid
keys in thetrackIdentity
prop (instead ofidentity
andtrackId
). -
Make sure you're listening to participant events via
onParticipant{Added/Removed}VideoTrack
rather thanonParticipant{Enabled/Disabled}Track
.
Contact
- MartÃn Fernández fmartin91@gmail.com
- Gaston Morixe gaston@gastonmorixe.com
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
9 commit(s) and 6 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
binaries present in source code
Details
- Warn: binary detected: Example/android/gradle/wrapper/gradle-wrapper.jar:1
Reason
Found 6/22 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/node.js.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/blackuy/react-native-twilio-video-webrtc/node.js.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/blackuy/react-native-twilio-video-webrtc/node.js.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 15 are checked with a SAST tool
Reason
41 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx
- Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4
- Warn: Project is vulnerable to: GHSA-rxrc-rgv4-jpvx
- Warn: Project is vulnerable to: GHSA-7f53-fmmv-mfjv
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp
- Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-w5p7-h5w8-2hfq
- Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
Score
3.9
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More