Gathering detailed insights and metrics for @wrethink/react-native-twilio-video-webrtc-wtk
Gathering detailed insights and metrics for @wrethink/react-native-twilio-video-webrtc-wtk
Gathering detailed insights and metrics for @wrethink/react-native-twilio-video-webrtc-wtk
Gathering detailed insights and metrics for @wrethink/react-native-twilio-video-webrtc-wtk
npm install @wrethink/react-native-twilio-video-webrtc-wtk
Typescript
Module System
Node Version
NPM Version
41.9
Supply Chain
81.4
Quality
64
Maintenance
25
Vulnerability
95
License
Cumulative downloads
Total Downloads
Last day
0%
0
Compared to previous day
Last week
0%
0
Compared to previous week
Last month
0%
0
Compared to previous month
Last year
0%
0
Compared to previous year
4
Platforms:
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.
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.
Add the Twilio dependency to your Podfile:
1pod 'TwilioVideo'
Install Pods:
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's "Linked Frameworks and Libraries".
Update the settings of your project as follows:
Build Settings
, find Search Paths
.Framework Search Paths
and Library Search Paths
by adding $(SRCROOT)/../node_modules/react-native-twilio-video-webrtc/ios
with recursive
.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>
TwilioVideo version 1.3.8 (latest) has the following know issues.
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')
}
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 }
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.
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.** { *; }
You can see the documentation here.
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 viewHere 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 roomName: '', 16 token: '' 17 } 18 19 _onConnectButtonPress = () => { 20 this.refs.twilioVideo.connect({ roomName: this.state.roomName, accessToken: this.state.token }) 21 this.setState({status: 'connecting'}) 22 } 23 24 _onEndButtonPress = () => { 25 this.refs.twilioVideo.disconnect() 26 } 27 28 _onMuteButtonPress = () => { 29 this.refs.twilioVideo.setLocalAudioEnabled(!this.state.isAudioEnabled) 30 .then(isEnabled => this.setState({isAudioEnabled: isEnabled})) 31 } 32 33 _onFlipButtonPress = () => { 34 this.refs.twilioVideo.flipCamera() 35 } 36 37 _onRoomDidDisconnect = ({roomName, error}) => { 38 console.log("ERROR: ", error) 39 40 this.setState({status: 'disconnected'}) 41 } 42 43 _onRoomDidFailToConnect = (error) => { 44 console.log("ERROR: ", error) 45 46 this.setState({status: 'disconnected'}) 47 } 48 49 _onParticipantAddedVideoTrack = ({participant, track}) => { 50 console.log("onParticipantAddedVideoTrack: ", participant, track) 51 52 this.setState({ 53 videoTracks: new Map([ 54 ...this.state.videoTracks, 55 [track.trackSid, { participantSid: participant.sid, videoTrackSid: track.trackSid }] 56 ]), 57 }); 58 } 59 60 _onParticipantRemovedVideoTrack = ({participant, track}) => { 61 console.log("onParticipantRemovedVideoTrack: ", participant, track) 62 63 const videoTracks = this.state.videoTracks 64 videoTracks.delete(track.trackSid) 65 66 this.setState({videoTracks: { ...videoTracks }}) 67 } 68 69 render() { 70 return ( 71 <View style={styles.container}> 72 { 73 this.state.status === 'disconnected' && 74 <View> 75 <Text style={styles.welcome}> 76 React Native Twilio Video 77 </Text> 78 <TextInput 79 style={styles.input} 80 autoCapitalize='none' 81 value={this.state.roomName} 82 onChangeText={(text) => this.setState({roomName: text})}> 83 </TextInput> 84 <TextInput 85 style={styles.input} 86 autoCapitalize='none' 87 value={this.state.token} 88 onChangeText={(text) => this.setState({token: text})}> 89 </TextInput> 90 <Button 91 title="Connect" 92 style={styles.button} 93 onPress={this._onConnectButtonPress}> 94 </Button> 95 </View> 96 } 97 98 { 99 (this.state.status === 'connected' || this.state.status === 'connecting') && 100 <View style={styles.callContainer}> 101 { 102 this.state.status === 'connected' && 103 <View style={styles.remoteGrid}> 104 { 105 Array.from(this.state.videoTracks, ([trackSid, trackIdentifier]) => { 106 return ( 107 <TwilioVideoParticipantView 108 style={styles.remoteVideo} 109 key={trackSid} 110 trackIdentifier={trackIdentifier} 111 /> 112 ) 113 }) 114 } 115 </View> 116 } 117 <View 118 style={styles.optionsContainer}> 119 <TouchableOpacity 120 style={styles.optionButton} 121 onPress={this._onEndButtonPress}> 122 <Text style={{fontSize: 12}}>End</Text> 123 </TouchableOpacity> 124 <TouchableOpacity 125 style={styles.optionButton} 126 onPress={this._onMuteButtonPress}> 127 <Text style={{fontSize: 12}}>{ this.state.isAudioEnabled ? "Mute" : "Unmute" }</Text> 128 </TouchableOpacity> 129 <TouchableOpacity 130 style={styles.optionButton} 131 onPress={this._onFlipButtonPress}> 132 <Text style={{fontSize: 12}}>Flip</Text> 133 </TouchableOpacity> 134 <TwilioVideoLocalView 135 enabled={true} 136 style={styles.localVideo} 137 /> 138 </View> 139 </View> 140 } 141 142 <TwilioVideo 143 ref="twilioVideo" 144 onRoomDidConnect={ this._onRoomDidConnect } 145 onRoomDidDisconnect={ this._onRoomDidDisconnect } 146 onRoomDidFailToConnect= { this._onRoomDidFailToConnect } 147 onParticipantAddedVideoTrack={ this._onParticipantAddedVideoTrack } 148 onParticipantRemovedVideoTrack= { this._onParticipantRemovedVideoTrack } 149 /> 150 </View> 151 ); 152 } 153} 154 155AppRegistry.registerComponent('Example', () => Example);
To run the example application:
cd Example
yarn install
cd ios && pod install
open Example.xcworkspace
s.dependency 'TwilioVideo', '~> 2.2.0'
sid
/trackSid
field.
The trackId
field no longer exists and should be replaced by trackSid
. Commensurate with this change,
participant views now expect participantSid
and videoTrackSid
keys in the trackIdentity
prop (instead of
identity
and trackId
).No vulnerabilities found.
No security vulnerabilities found.