'incomingCall' listener not working . Getting error "Callingcommunicatoirerror at callAgentImpl.on" when using callAgent.on('incomingCall', handleIncomingCall) in reactjs

Ramakrishna Samanta 0 Reputation points
2024-06-10T09:38:38.4933333+00:00

No incoming event getting called when a remote participants join the call or exit from the call.

I have used the below code in App.js

const { token, user } = await fetchTokenResponse(); const tokenCredential = new AzureCommunicationTokenCredential(token);

    const callClient = new CallClient();

    const callAgent = await callClient.createCallAgent(tokenCredential);

	callAgent.on('incomingCall', (incomingCallEvent) => {

          console.log('Incoming call event:', incomingCallEvent);


      });

We have used the github link : https://github.com/Azure-Samples/communication-services-web-calling-hero

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
748 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 19,511 Reputation points
    2024-06-13T13:18:14.16+00:00

    @Ramakrishna Samanta Thanks for asking question!

    Remote participants in a call are represented by the RemoteParticipant type. These participants can be accessed through the remoteParticipants collection in a call instance.

    Listing Participants in a Call:

    To retrieve the list of remote participants in a call, use the getRemoteParticipants method on the call instance. This method returns a list of RemoteParticipant objects.

    
    List<RemoteParticipant> remoteParticipants = call.getRemoteParticipants(); // [remoteParticipant, remoteParticipant....]
    

    This code snippet fetches all remote participants in the call and stores them in a list.

    Adding a Participant to a Call-

    To add a new participant to a call, whether it's a user or a phone number, use the addParticipant method. This method will synchronously return the instance of the newly added remote participant.

    1. Adding participant and Phone Number-
         const acsUser = new CommunicationUserIdentifier("<acs user id>"); const acsPhone = new PhoneNumberIdentifier("<phone number>"); RemoteParticipant remoteParticipant1 = call.addParticipant(acsUser); AddPhoneNumberOptions addPhoneNumberOptions = new AddPhoneNumberOptions(new PhoneNumberIdentifier("<alternate phone number>")); RemoteParticipant remoteParticipant2 = call.addParticipant(acsPhone, addPhoneNumberOptions);
      
      Here, a user identified by their Azure Communication Services (ACS) user ID is added to the call. In this example, a participant is added to the call using a phone number. Additional options can be specified using AddPhoneNumberOptions.

    Hope this helps, please let us know if issue remains!

    0 comments No comments