-
Notifications
You must be signed in to change notification settings - Fork 36
Description
So I tried everything, starting from installing latest SDK version, latest React Native, running app on Android studio even on physical device as well, still this issue persisted.
Then I tried to install the versions that are being used in sample app i.e SDK 1.2 and react native 0.72 still this issue didn't go.
I tried contacting with support they were just insisting to use the sample app which I have no interest because my client has a different UI and some different approach to use the mobile app.
Just to mention here is that I was able to successfully implement calls on web app but failed on mobile.
Below is the code that I tried.
`import { useEffect, useState } from 'react';
import axios from "./axios";
import { Voice } from '@twilio/voice-react-native-sdk';
const voice = new Voice ();
export default function App () {
const [ callToken, setCallToken ] = useState ( '' );
function token () {
axios.post ( 'token', {
identity: '[[email protected]](mailto:[email protected])'
} )
.then ( ( response ) => {
setCallToken ( response.data.call );
} )
.catch ( ( error ) => {
console.log ( error )
} )
}
useEffect ( () => {
token ();
}, [] );
useEffect ( () => {
if ( callToken.length > 0 ) {
console.log ( callToken );
voice.register ( callToken ).then ( () => console.log ( 'registered' ) );
}
}, [ callToken ] );
return (
<></>
);
}`
I also tried to split the code into further components e.g instead of useEffect I created a button to click and then register voice, this is because may be loading sdk takes time so better to use button and wait 1-2 seconds before registering but still no success.