callstack / react-native-opentok

React Native OpenTok
202 stars 79 forks source link

unable to connect #81

Open richielo opened 6 years ago

richielo commented 6 years ago

Hi I am trying to connect to a session with a publisher. The session id and token are obtained from a nodejs server while the publisher in the session is connected through the browser. When I run this (code below) on my android emulator, it fails to connect even though the session id and token are obtained. I am rather new to this. What am I doing wrong here? Thank you very much for your help in advance.


async componentWillMount() {
    console.log("in will mount");
    const connectToSession = async () => {
      try {
        await this.getLiveSession();
        console.warn("Done retrieving sessionId");
        console.log("Session id: " + this.state.sessionId);
        await this.getLiveToken();
        console.warn("Done retrieving token");
        console.log("Token: " + this.state.sessionToken);
        await OpenTok.connect(this.state.sessionId, this.state.sessionToken);
        console.warn("Done connecting to session");
        this.setState({isLoading:false},function(){

        });
      } catch (e) {
        console.log(e)
      }
    }
    await connectToSession();
  }```

12-27 14:07:03.080  6558  6635 I ReactNativeJS: { [TypeError: undefined is not an object (evaluating '_reactNative.NativeModules.RNOpenTok.connect')]
12-27 14:07:03.080  6558  6635 I ReactNativeJS:   line: 52033,
12-27 14:07:03.080  6558  6635 I ReactNativeJS:   column: 48,