react-native-callkeep icon indicating copy to clipboard operation
react-native-callkeep copied to clipboard

displayIncomingCall ignored due to no ConnectionService or no phone account

Open Sheharyar566 opened this issue 3 years ago • 8 comments

Bug report

I've setup the call keep as mentioned in the documentation with selfManaged: true on android , and am looking at the debug logs (also mentioned in the documentation), but I'm getting the following error in the debug logs displayIncomingCall ignored due to no ConnectionService or no phone account

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

  • Reproduced on:

  • [x] Android

  • [ ] iOS

Description

I'm calling the stuff in a file called call.screen.tsx which calls the listeners as:

  useEffect(() => {
    const initCallKeep = async () => {
      try {
        const options: IOptions = {
          ios: {
            appName: 'My app name',
          },
          android: {
            alertTitle: 'Permissions required',
            alertDescription: 'This application needs to access your phone accounts',
            cancelButton: 'Cancel',
            okButton: 'ok',
            imageName: 'phone_account_icon',
            additionalPermissions: [],
            selfManaged: true,
            // Required to get audio in background when using Android 11
            foregroundService: {
              channelId: 'com.company.my',
              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);
        await RNCallKeep.setup(options);
      } catch (e) {
        console.error('Error occured while initializing callkeep: ', e);
        showError(e);
      }
    };

    initCallKeep();
  }, []);

  const actionHandler = (action: string) => {
    console.log('Called handler for action: ', action);
  };

  useEffect(() => {
    Api.on(ApiEvent.IncomingCall, onIncomingCall);
    Api.on(ApiEvent.CallUpdate, onCallUpdated);

    RNCallKeep.addEventListener('showIncomingCallUi', showCallUI);
    RNCallKeep.addEventListener('didReceiveStartCallAction', () => actionHandler('didReceiveStartCallAction'));
    RNCallKeep.addEventListener('answerCall', () => actionHandler('answerCall'));
    RNCallKeep.addEventListener('endCall', () => actionHandler('endCall'));
    RNCallKeep.addEventListener('didDisplayIncomingCall', () => actionHandler('didDisplayIncomingCall'));
    RNCallKeep.addEventListener('didPerformSetMutedCallAction', () => actionHandler('didPerformSetMutedCallAction'));
    RNCallKeep.addEventListener('didPerformDTMFAction', () => actionHandler('didPerformDTMFAction'));

    return () => {
      Api.off(ApiEvent.IncomingCall, onIncomingCall);
      Api.off(ApiEvent.CallUpdate, onCallUpdated);

      RNCallKeep.removeEventListener('showIncomingCallUi');
      RNCallKeep.removeEventListener('didReceiveStartCallAction');
      RNCallKeep.removeEventListener('answerCall');
      RNCallKeep.removeEventListener('endCall');
      RNCallKeep.removeEventListener('didDisplayIncomingCall');
      RNCallKeep.removeEventListener('didPerformSetMutedCallAction');
      RNCallKeep.removeEventListener('didPerformDTMFAction');
    };
  }, []);

  const onIncomingCall = useCallback(
    async (data: ICall) => {
      try {
        if (isCalling) {
          throw 'Call Event Duplication: A call was already in progress while another incoming call event was received';
        }

        setBookingID(data.bookingId);
        setCallID(data.id);
        RNCallKeep.displayIncomingCall(data.id, 'Driver');
      } catch (e) {
        console.error('Failed to start the call: ', e);
        throw e;
      }
    },
    [isCalling],
  );

  const showCallUI = () => {
    setIsCalling(true);
    setStatus(CallStatus.Incoming);
    CallService.playRingTone();
  };

Steps to Reproduce

Versions

- Callkeep: ^4.3.3
- React Native: 0.69.5
- iOS: NA
- Android: 10
- Phone model: Xiaomi Redmi 8

Logs

11-02 16:40:09.765 24283 26727 D RNCallKeep: [VoiceConnectionService] setAvailable: true
11-02 16:40:09.765 24283 26727 D RNCallKeep: [VoiceConnectionService] setInitialized: true
11-02 16:40:09.770 24283 26727 D RNCallKeep: [RNCallKeepModule] setup
11-02 16:40:09.770 24283 26727 D RNCallKeep: [VoiceConnectionService] setAvailable: false
11-02 16:40:09.770 24283 26727 D RNCallKeep: [VoiceConnectionService] setInitialized: true
11-02 16:40:09.770 24283 26727 D RNCallKeep: [RNCallKeepModule] setSettings: { NativeMap: {"alertTitle":"Permissions required","foregroundService":{"channelId":"com.company.my","channelName":"Foreground service for my app","notificationTitle":"My app is running on background","notificationIcon":"Path to the resource icon of the notification"},"alertDescription":"This application needs to access your phone accounts","cancelButton":"Cancel","imageName":"phone_account_icon","okButton":"ok","selfManaged":true,"additionalPermissions":[]} }
11-02 16:40:09.772 24283 26727 D RNCallKeep: [RNCallKeepModule] API Version supports self managed, and is enabled in setup
11-02 16:40:09.772 24283 26727 D RNCallKeep: [RNCallKeepModule] setup, adding RECORD_AUDIO in permissions in self managed
11-02 16:40:09.772 24283 26727 D RNCallKeep: [RNCallKeepModule] registerPhoneAccount
11-02 16:40:09.840 24283 26727 D RNCallKeep: [RNCallKeepModule] registerEvents
11-02 16:40:09.840 24283 26727 D RNCallKeep: [RNCallKeepModule] startObserving, event count: 0
11-02 16:40:09.840 24283 26727 D RNCallKeep: [RNCallKeepModule] startObserving, event count: 0
11-02 16:40:09.840 24283 26727 D RNCallKeep: [VoiceConnectionService] setAvailable: true
11-02 16:40:09.840 24283 26727 D RNCallKeep: [VoiceConnectionService] setInitialized: true
11-02 16:40:43.990 24283 26727 W RNCallKeep: [RNCallKeepModule] displayIncomingCall ignored due to no ConnectionService or no phone account

Sheharyar566 avatar Nov 02 '22 11:11 Sheharyar566

did you manage to solve this problem?

wilmxre avatar Mar 09 '23 12:03 wilmxre

Nope... had to manually implement it on native side (android particularly - haven't had a chance to do it for iOS side yet).

Sheharyar566 avatar Mar 09 '23 12:03 Sheharyar566

thank you for the quick answer. what did you implement specifically on native side? i also have this problem on a lenovo tablet, the incoming call is not showing up, neither my outgoing calls are received. can you provide me some information about this, please?

wilmxre avatar Mar 09 '23 13:03 wilmxre

Nope... had to manually implement it on native side (android particularly - haven't had a chance to do it for iOS side yet).

yeah @wilmxre what did you exactly had to implement in the native side?

are you displaying the incoming call ui inside a time sensitive notification?

juxnpxblo avatar May 05 '23 15:05 juxnpxblo

i have an activity in android that i display when i get a call notification. i call callkeep's backToForeground method when i get the notification then i call my activity that is exposed to react-native via NativeModules

wilmxre avatar May 05 '23 15:05 wilmxre