README
How do I set up?
- In the root folder of your react-native project run
npm install react-native-opentok --save
rnpm link react-native-opentok
pod 'OpenTok'
pod install
###SAMPLE USAGE###
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import OpenTok from 'react-native-opentok'
var sampleServerBaseUrl = 'https://calm-ridge-14798.herokuapp.com',
sessionCredentialsUrl = sampleServerBaseUrl + '/session',
startArchiveUrl = sampleServerBaseUrl + '/start/',
stopArchiveUrl = sampleServerBaseUrl + '/stop/';
const TestView = React.createClass ({
getInitialState() {
return ({
apiKey: null,
sessionId: null,
token: null,
doConnect: false
});
},
componentWillMount() {
this.getApiKeyAndToken();
},
getApiKeyAndToken() {
var xhr = new XMLHttpRequest();
xhr.open("GET", sessionCredentialsUrl, true);
var self = this;
xhr.onload = function (e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
openTokSessionInfo = JSON.parse(xhr.responseText);
self.setState({
apiKey: openTokSessionInfo.apiKey,
sessionId: openTokSessionInfo.sessionId,
token: openTokSessionInfo.token
doConnect: true
});
} else {
console.log(xhr.statusText);
}
}
};
xhr.onerror = function (e) {
console.log(xhr.statusText);
};
xhr.send(null);
},
didDisconnect() {
},
render() {
return (
<View style={styles.container}>
<OpenTok doConnect={this.state.doConnect} apiKey={this.state.apiKey} sessionId={this.state.sessionId} token={this.state.token}/>
</View>
);
}
});
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
}
});
AppRegistry.registerComponent('test', () => TestView);