react-native-webrtc / react-native-webrtc/react-native-callkeep

selfManaged mode not showing call in Call History

Open
#539 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.1k
Forks
511
Avg merge
9h 12m
Merged PRs (30d)
2

Description

Bug report

  • I've checked the example to reproduce the issue.

  • Reproduced on:

  • Android

  • iOS

Description

Android only:
Call Keeps Works perfectly fine and I can see recent calls in phones Call History.
However when I switch to selfManaged mode, present my UI (notification + foreground service) Call Keeps starts and ends as expected but calls are not visible in Call History on the phone, is this normal Call Keep behavior for android??

Register CallKeep

  async initializeCallKeep(appName: string) {
    try {
      RNCallKeep.setup({
        ios: {
          appName: appName,
        },
        android: {
          alertTitle: 'Permissions required',
          alertDescription:
            'This application needs to access your phone accounts',
          cancelButton: 'Cancel',
          okButton: 'ok',
          additionalPermissions: [],
          selfManaged: true,
          foregroundService: {
            channelId: 'acu_incoming_call',
            channelName: 'Foreground service for my app',
            notificationTitle: 'My app is running on background',
            notificationIcon: 'Path to the resource icon of the notification',
          },
        },
      });
      RNCallKeep.setAvailable(true);
    } catch (err: any) {
      console.error('initializeCallKeep error:', err.message);
    }
    console.log('$$$ CallKeep Initialized $$$, ', appName);

    // Add RNCallKit Events
    RNCallKeep.addEventListener(
      'didDisplayIncomingCall',
      this.onIncomingCallDisplayed.bind(this)
    );
    RNCallKeep.addEventListener('answerCall', this.answerCall.bind(this));
    RNCallKeep.addEventListener(
      'didPerformDTMFAction',
      this.onPerformDTMFAction.bind(this)
    );
    RNCallKeep.addEventListener(
      'didReceiveStartCallAction',
      this.onReceiveStartCallAction.bind(this)
    );
    RNCallKeep.addEventListener(
      'didPerformSetMutedCallAction',
      this.onPerformSetMutedCallAction.bind(this)
    );
    RNCallKeep.addEventListener('didActivateAudioSession', () => {
      // you might want to do following things when receiving this event:
      // - Start playing ringback if it is an outgoing call
      this.answerCall;
    });
    RNCallKeep.addEventListener(
      'showIncomingCallUi',
      ({ handle, callUUID, name }) => {
        this.displayCustomIncomingUI(handle, callUUID, name);
        console.log('********** Android showIncomingCallUi ********');
      }
    );
    RNCallKeep.addEventListener('endCall', this.rejectCallCallKeep.bind(this));

    // Android ONLY
    DeviceEventEmitter.addListener('rejectedCallAndroid', (payload) => {
      // End call action here
      console.log('endCallAndroid REACT NATIVE REACT NATIVE', payload);
      this.rejectCallCallKeep();
    });

    // Android ONLY
    DeviceEventEmitter.addListener('answeredCallAndroid', (payload) => {
      console.log('answerCallAndroid REACT NATIVE REACT NATIVE', payload);
      this.answerCall();
    });
  }

Answer call

  answerCall() {
    this.setState({ callType: 'client' });
    if (!this.state.callAnswered) {
      this.answer();
      this.setState({ callAnswered: true });
      this.terminateCallIfNotConnected();
    }
    RNCallKeep.setCurrentCallActive(<string>this.state.callUuid);
    this.setState({ incomingUUI: false });
  }

answer Call CallKeep

  async answer(): Promise<void> {
    if (this.state.call !== null && this.state.callState === 'incoming call') {
      this.state.callOptions.constraints = { audio: true, video: true };
      this.state.callOptions.receiveAudio = true;
      this.state.callOptions.receiveVideo = true;
      this.state.call.answer(this.state.callOptions);
      this.getCallUuid();
      RNCallKeep.answerIncomingCall(<string>this.state.callUuid);
      console.log('CALL ANSWERED WITH CALLKEEP', this.state.callUuid);
    }
  }

display custom UI

 incomingCallNotification(
          'acu_incoming_call',
          'Incoming call',
          'channel used to display incoming call notification',
          this.state.incomingCallClientId,
          1986
        );
        RNCallKeep.displayIncomingCall(
          <string>this.state.callUuid,
          this.state.incomingCallClientId,
          this.state.incomingCallClientId
        );

onCallDisconnected

  afterDisconnected(): void {
    this.setState({ callAnswered: false });
    this.endCallKeepCall(<string>this.state.callUuid); //TEST
    console.log('*********8 DISCONNEDCTED FIRED UP ********');
  }

Reject the call

  rejectCallCallKeep() {
    try {
      RNCallKeep.rejectCall(<string>this.state.callUuid);
      this.reject();
    } catch (err: any) {
      console.error('rejectCallCallKeep error:', err.message);
    }
  }

Steps to Reproduce

Versions

- Callkeep: 4.3.2
- React Native: 0.66.0
- iOS:
- Android: 8.1.0
- Phone model: Moto G5 Plus

Logs

Paste here

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Android selfManaged configuration passed to RNCallKeep.setup, then trace displayIncomingCall, answerIncomingCall, and rejectCall in the Android call flow. Reproduce the reported setup on Android 8.1 and compare whether selfManaged calls are expected to reach phone Call History; done should clarify the supported behavior or identify the missing integration step.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, react-native, typescript
Domain
audio-video-rtc, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.