Currently, I am in the process of integrating the OpenTok Lib into my react-native project. However, I have encountered some issues that I have not been able to resolve yet. The main issue is that when attempting to connect as a Subscriber to a session, the app crashes on android devices. This prevents me from testing the connection between two phones.
I am seeking assistance to figure out what might be causing this problem.
Appointment
import React, { Component } from 'react';
import { OTSession } from 'opentok-react-native';
import { TokBox } from '../../../helpers/constants';
import PublisherStream from './PublisherStream';
import SubscriberStream from './SubscriberStream';
class Appointment extends Component {
static navigationOptions = {
header: null
};
render() {
const { navigation: { navigate, state: { params } } } = this.props;
return (
<OTSession style={{ flex: 1 }}
apiKey={TokBox.API_KEY}
sessionId={params.sessionId}
token={params.token}
eventHandlers={this.sessionEventHandlers}>
<PublisherStream style={{ borderColor: 'red', borderWidth: 3, height: '50%' }} />
<SubscriberStream style={{ borderColor: 'blue', borderWidth: 3, height: '50%' }} />
</OTSession>
);
}
}
export default Appointment;
PublisherStream
import React, { Component } from 'react';
import { OTPublisher } from 'opentok-react-native';
class PublisherStream extends Component {
publisherEventHandlers = {
streamCreated: (event) => {
console.log('Publisher stream created!', event);
},
streamDestroyed: (event) => {
console.log('Publisher stream destroyed!', event);
}
};
render() {
return (
<OTPublisher style={this.props.style} eventHandlers={this.publisherEventHandlers} />
);
}
}
export default PublisherStream;
SubscriberStream
import React, { Component } from 'react';
import { OTSubscriber } from 'opentok-react-native';
class SubscriberStream extends Component {
subscriberProperties = {
subscribeToAudio: true,
subscribeToVideo: true,
};
subscriberEventHandler = {
connected(event) {
console.log('connected', event);
},
disconnected(event) {
console.log('disconnected', event);
},
videoDataReceived(event) {
console.log('videoDataReceived', event);
},
videoEnabled(event) {
console.log('videoEnabled', event);
},
videoNetworkStats(event) {
console.log('videoNetworkStats', event);
}
};
render() {
return (
<OTSubscriber
properties={this.subscriberProperties}
eventHandlers={this.subscriberEventHandler}
style={this.props.style}
/>
);
}
}
export default SubscriberStream;
Package.json
{
{...omitted}
"dependencies": {
"opentok-react-native": "^0.9.5",
"react": "^16.8.1",
"react-native": "0.58.4",
},
{...omitted}
}