Skip to content

Twilio android ref fix #775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ dependencies {
.....
.....
.....
implementation project(':react-native-twilio-video-webrtc')
implementation(project(':react-native-twilio-video-webrtc'))
}
```

Expand All @@ -177,8 +177,8 @@ You will also need to update this file so that you compile with java 8 features:
```
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
```
Expand All @@ -200,6 +200,25 @@ Then update the `getPackages()` method:
}
```

If your React Native project uses Kotlin for the `MainApplication`, follow these steps to manually add the `TwilioPackage`.


At the top of your `MainApplication.kt` file, add:

```kotlin
import com.twiliorn.library.TwilioPackage
```
Now update the `getPackages()` method by adding:
```kotlin
override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
...
add(TwilioPackage())
}
```

### Permissions

For most applications, you'll want to add camera and audio permissions to your `AndroidManifest.xml` file:
Expand Down
10 changes: 8 additions & 2 deletions src/TwilioVideo.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ const nativeEvents = {
};

class CustomTwilioVideoView extends Component {
constructor(props) {
super(props);
// Use createRef instead of string ref to fix warning
this.videoViewRef = React.createRef();
}

connect({
roomName,
accessToken,
Expand Down Expand Up @@ -271,7 +277,7 @@ class CustomTwilioVideoView extends Component {
switch (Platform.OS) {
case "android":
UIManager.dispatchViewManagerCommand(
findNodeHandle(this.refs.videoView),
findNodeHandle(this.videoViewRef.current),
event,
args
);
Expand Down Expand Up @@ -320,7 +326,7 @@ class CustomTwilioVideoView extends Component {
render() {
return (
<NativeCustomTwilioVideoView
ref="videoView"
ref={this.videoViewRef}
{...this.props}
{...this.buildNativeEventWrappers()}
/>
Expand Down