@twilio/voice-sdk
    Preparing search index...

    Function incomingEvent

    • Emitted when an incoming Call is received. You can interact with the call object using its public APIs, or you can forward it to a different Device using Device.connect and Call.connectToken, enabling your application to receive multiple incoming calls for the same identity.

      Important: When forwarding a call, the token for target device instance needs to have the same identity as the token used in the device that originally received the call.

      Parameters

      Returns void

      const receiverDevice = new Device(token, options);
      await receiverDevice.register();

      receiverDevice.on('incoming', (call) => {
      // Forward this call to a new Device instance using the call.connectToken string.
      forwardCall(call.connectToken);
      });

      // The forwardCall function may look something like the following.
      async function forwardCall(connectToken) {
      // For every incoming call, we create a new Device instance which we can
      // interact with, without affecting other calls.
      // IMPORTANT: The token for this new device needs to have the same identity
      // as the token used in the receiverDevice.
      const device = new Device(token, options);
      const call = await device.connect({ connectToken });

      // Destroy the device after the call is completed
      call.on('disconnect', () => device.destroy());
      }