react-native-twilio-programmable-voice: `TwilioVoice.initWithToken()` and `TwilioVoice.connect()` did not work properly on iOS 10.2 simulator

TwilioVoice.initWithToken() and TwilioVoice.connect() did not work properly, after connect executed it nothing is happening. And also whatever the token used on initWithToken (e.g. random string), it always return:

{
  initilized: true,
}

Here is the code that I use:

import React, {Component} from 'react';
import {StyleSheet, Text, View, Button} from 'react-native';
import TwilioVoice from 'react-native-twilio-programmable-voice';

export default class App extends Component {
  constructor() {
    super(...arguments);
    this.state = {
      success: false,
    };
  }

  async componentWillMount() {
    try {
      let success = await TwilioVoice.initWithToken('token');
      console.log(success);
      this.setState({success});
      TwilioVoice.addEventListener('connectionDidConnect', () => {
        console.log('>> TwilioVoice, Call connected.');
      });
      TwilioVoice.addEventListener('connectionDidDisconnect', () => {
        console.log('>> TwilioVoice, Call disconnected.');
      });
    } catch (e) {
      console.log('error token:', e);
    }
  }

render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Welcome!</Text>
        <Button
          title="Call"
          onPress={() => {
            if (this.state.success && this.state.success.initilized) {
              try {
                console.log('>> TwilioVoice, Calling...');
                TwilioVoice.connect({To: '+62123456789'});
              } catch (e) {
                console.log('>> error:', e);
              }
            }
          }}
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
});

What version of React Native are you running?

I use RN v0.47.2

What version of react-native-twilio-programmable-voice are you running?

I use v2.8.0

What device are you using? (e.g iOS9 simulator, Android 6 device)?

I use iOS 10.2 simulator

Is your app running in foreground, background or not running?

It’s running on foreground

Is there any relevant message in the log?

Nope, nothing

If using iOS, which pod version are you using?

I use pod v1.31

Step to reproduce

Just run it normally

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16

Most upvoted comments

Hi, I am using version 2.8 with RN 0.45 and I don’t experience any problems connecting. As a first troubleshooting I will always recommend to try and run a compete working example with the official twilio quickstart apps. Once that works you would exclude any possibilities of misconfiguration with access tokens.

Once Callkit is initialised you can clearly read about it inside xcode logs. If you can’t see that, there are issues on initialization. The fact that init always returns initialized: true is not ideal. I made it so to even up the behaviour between android and iOS, since that allows for JavaScript simplifications in the code that uses the library.

Please let me know if this helps at all