0

I'm using Agora.io in my react native project for video calling and I want to know when I will call tom someone and I'll join the channel but how can I' show incoming call UI in-app on the receiver mobile. So that he can also join the channel to start the call. Kindly if you have any resources let me know. Thanks

Here is the code for initialize agro sdk

init = async () => {
    const {appId} = this.state;
    this._engine = await RtcEngine.create(appId);
    await this._engine.enableVideo();
    this.startCall();
    this._engine.addListener('Warning', (warn) => {
      console.log('Warning', warn);
    });

    this._engine.addListener('Error', (err) => {
      console.log('Error', err);
    });

    this._engine.addListener('UserJoined', (uid, elapsed) => {
      console.log('UserJoined', uid, elapsed);
      // Get current peer IDs
      const {peerIds} = this.state;
      // If new user
      if (peerIds.indexOf(uid) === -1) {
        this.setState({
          // Add peer ID to state array
          peerIds: [...peerIds, uid],
        });
      }
    });

    this._engine.addListener('UserOffline', (uid, reason) => {
      console.log('UserOffline', uid, reason);
      const {peerIds} = this.state;
      this.setState({
        // Remove peer ID from state array
        peerIds: peerIds.filter((id) => id !== uid),
      });
    });

    // If Local user joins RTC channel
    this._engine.addListener('JoinChannelSuccess', (channel, uid, elapsed) => {
      console.log('JoinChannelSuccess', channel, uid, elapsed);
      // Set state variable to true
      this.setState({
        joinSucceed: true,
      });
    });
  };

Here is the code for Start Call

 startCall = async () => {
    // Join Channel using null token and channel name
    await this._engine?.joinChannel(
      this.state.token,
      this.state.channelName,
      null,
      0,
    );
  };

how the receiver can receive the call

Zaid Qureshi
  • 155
  • 3
  • 12

1 Answers1

0

Agora SDK does not have any built-in functionality for this. A fantastic library for this would be react-native-callkeep.

https://github.com/react-native-webrtc/react-native-callkeep

Essentially, this library will help you draw a UI when someone tries to call you. It uses firebase push notifications to notify the callee.

vineeth srini
  • 444
  • 2
  • 5