react-native-webrtc / react-native-callkeep

iOS CallKit framework and Android ConnectionService for React Native
ISC License
918 stars 444 forks source link

showIncomingCallUi is never fired in self-mode #733

Open folin03 opened 1 year ago

folin03 commented 1 year ago

Description

I run RNCK in self-mode.


const initializeCallKeep = async () => {
  const iosSetup = {
    appName: appName,
    supportsVideo: true,
  };

  let androidSetup = {
    alertTitle: 'Permissions required',
    alertDescription: 'This application needs to access your phone accounts',
    cancelButton: 'Cancel',
    okButton: 'ok',
    selfManaged: true,
  };

  if (platform === 'android' && Platform.Version >= 30) {
    androidSetup.foregroundService = {
      channelId: 'callkeep_channel',
      channelName: 'Foreground service',
      notificationTitle: 'My app is running on background',
      notificationIcon: 'Path to the resource icon of the notification',
    };
  }

  const res = await RNCallKeep.setup({
    ios: iosSetup,
    android: androidSetup,
  });
  console.log('CallKeep Initialized', appName, res);
};

after calling

RNCallKeep.displayIncomingCall(
    activeCall.call.callUuid,
    activeCall.name,
    activeCall.name,
    'generic',
    true,
  );

showIncomingCallUi is never fired. I listen to it. Throughout the logs I didn't find any error but also I do not get how is the event fired. displayIncomingCall in native modules runs ok but does not fire showIncomingCallUi. for test I have triggered the showIncomingCallUi manualy on the bottom of native displayIncomingCall function and as expected that triggered my code in RN when I ended the call by calling RNCallKeep.endCall(uuid); android log gave me this:

[RNCallKeepModule] endCall called, uuid: 88804f55-e449-4233-980b-808a46174abf [RNCallKeepModule] endCall ignored because no connection found, uuid: 88804f55-e449-4233-980b-808a46174abf

Would you have any suggestion where to look to fix it?

folin03 commented 1 year ago

A little update, I have run few more tests and none of the event listeners are triggered on Android.

mariouzae commented 1 year ago

Does your device support connection service? you can check that calling the RNCallKeep.supportConnectionService(); method. Also, you can listen to the createIncomingConnectionFailed event and check for errors.

folin03 commented 1 year ago

Yes the device runs Android 12 and it supports ConnectionService. createIncomingConnectionFailed is never fired but also onCreateIncomingConnection is never fired. On android I don't get any events e.g. after calling endCall endCall event listener is not trigered but it works fine on iOS. It used to work. I haven't work on the Android side of he app for few months. Last it was tested on Android 11. I updated to Android 12. The app ment to go for release so I run last test and found out this disaster.

danilvalov commented 11 months ago

I had the same problem when RNCallKeep.displayIncomingCall fired but showIncomingCallUi listener doesn't. I found a message in native android logs about calling displayIncomingCall with the following:

[RNCallKeepModule] sendEventToJS, eventName: RNCallKeepShowIncomingCallUi, bound: true, hasListeners: false

So I saw hasListeners: false and just moved RNCallKeep.setup() and RNCallKeep.addEventListener('showIncomingCallUi', ...) to main index.js file of my react native app, and it fixed this issue.