Skip to content

Twilio Incoming voice not working in IOS and Android using React Native Twilio Voice SDK #658

@TechRandhawa

Description

@TechRandhawa

Hey, I am using the voice sdk and facing issue in incoming calls

this packages installed

"@react-native-firebase/app": "^23.2.0",
"@react-native-firebase/firestore": "^23.2.0",
"@react-native-firebase/messaging": "^23.2.0",
"@twilio/conversations": "^2.6.5",
"@twilio/voice-react-native-sdk": "^1.7.0",

The SDK registration is successful by both Android and IOS by using this code

import { Platform } from 'react-native';
import { voice } from './voiceSingleton';
import * as TwilioVoice from '@twilio/voice-react-native-sdk';
let currentCall = null;
let activeToken = null; // Store token for making calls later

export async function setupVoice(token) {
activeToken = token;

try {
voice.on(TwilioVoice.Voice.Event.CallInvite, (callInvite) => {
console.log('📞 Incoming call:', callInvite.getFrom());

callInvite.on('accepted', (call) => {
  console.log('✅ Call accepted');
});

callInvite.on('cancelled', () => {
  console.log('❌ Call cancelled');
});
callInvite.on('busy', () => {
  console.log('❌ Call busy');
});
});

voice.on(TwilioVoice.Voice.Event.Registered, () => {
console.log('✅ Registered');
});

voice.on(TwilioVoice.Voice.Event.Error, (err) => {
console.error('❌ Voice error', err);
});
} catch (error) {
console.error(error);

}

try {
if (Platform.OS === "ios") {
await voice.initializePushRegistry();
}
await voice.register(token);
console.log("✅ Voice SDK Registered");

voice.on(TwilioVoice.Voice.Event.CallInvite, (callInvite) => {
callInvite.accept();
});
} catch (error) {
console.error("❌ Registration failed:", error);
}

}

Console output is:
//✅ Registered
//✅ Voice SDK Registered

and First issue is SDK did not get the incoming call on both Android and IOS devices. Call invites did not get the incoming call

But I got FCM only on Android with data not on IOS by using following code but this code also has error

import messaging from '@react-native-firebase/messaging';
import { Voice } from '@twilio/voice-react-native-sdk';

const voice = new Voice();

messaging().onMessage(async (remoteMessage) => {
voice.handleFirebaseMessage(remoteMessage.data); // important, note the .data here
});

messaging().setBackgroundMessageHandler(async (remoteMessage) => {
voice.handleFirebaseMessage(remoteMessage.data); // likewise, note the .data here
});

this voice.handleFirebaseMessage(remoteMessage.data)
got this Error
ERROR [Error: Method invocation invalid]

Like other SDKs Twilio should handle Incoming call by itself with callInvites?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions