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

"createIncomingConnectionFailed" event is fired every time I show the incoming call ui in self managed mode

Open
#665 3 comments 1 reaction 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

I'm using self managed mode for android. I'm using react-native-firebase to listen for fcm messages and Notifee to register a foreground service and build notifications. Here's what I'm doing in my index.js:

RNCallKeep.setup({
  android: {
    alertTitle: 'Permissions required',
    alertDescription: 'This application needs to access your phone account',
    cancelButton: 'Cancel',
    okButton: 'Ok',
    selfManaged: true,
  },
});

// creates an android notification channel for incoming calls
notifee.createChannel({
  id: 'call',
  name: 'Incoming Call',
  importance: AndroidImportance.HIGH,
});

// creates a foreground service
notifee.registerForegroundService((notification) => {
  return new Promise(() => {
    notifee.onBackgroundEvent(async ({ type, detail }) => {
      // handle interactions with incoming call notification when app is in background
    });
    notifee.onForegroundEvent(async ({ type, detail }) => {
      // handle interactions with the incoming call notification when app is in foreground
    });
  });
});

// creates a headless js task to listen for background messages
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
  // If message is an incoming call
  RNCallKeep.displayIncomingCall();
});

In my app I have a useEffect which adds callkeep event listeners including:

RNCallKeep.addEventListener('showIncomingCallUi', ({ handle, callUUID, name }) => {
      notifee.displayNotification({
        id: callUUID,
        title: name || handle,
        body: 'Incoming call',
        android: {
          channelId: 'call',
          asForegroundService: true,
          category: AndroidCategory.CALL,
          fullScreenAction: { id: 'call' },
          actions: [
            { title: 'Decline', pressAction: { id: 'endCall' } },
            { title: 'Accept', pressAction: { id: 'answerCall' } },
          ],
          importance: AndroidImportance.HIGH,
        },
      });
    });

This builds a notification with full screen intent, high priority and associates it with a foreground service that I defined in my AndroidManifest.xml:

<service android:name="app.notifee.core.ForegroundService" android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE" android:foregroundServiceType="camera|microphone">
  <intent-filter>
    <action android:name="android.telecom.ConnectionService"/>
  </intent-filter>
</service>

When I receive an incoming call when my app is in the background state. My background message handler calls RNCallkeep.displayIncomingCall(), the 'showIncomingCallUi' event is fired, and I display the notification associated to the foreground service. The "createIncomingConnectionFailed" is then fired every time, which ends the call and the service. When the app is in the foreground state everything works. I have verified that my device has granted all permissions and I even added additional permissions to my AndroidManifest.xml:

  <uses-permission android:name="android.permission.READ_CALL_LOG"/>
  <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
  <uses-permission android:name="android.permission.MANAGE_OWN_CALLS"/>

I'll also add that I have not removed the callkeep foreground service from my AndroidManifest.xml. It's unclear from the docs whether I need to remove that service or not when using self managed mode and if so, what additional steps there are to take when removing the service. I tried a build where I removed the callkeep foreground service but got the error: PhoneAccount connection service requires BIND_TELECOM_CONNECTION_SERVICE permission.

Any possible reasons why this may be occurring is appreciated.

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 background message handler in index.js, the showIncomingCallUi and createIncomingConnectionFailed listeners, and the service declarations in AndroidManifest.xml. Reproduce the background and foreground flows, then trace the self-managed Android connection setup; done means the background call does not emit createIncomingConnectionFailed and the incoming-call notification remains active.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.