Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CallKeep Not Keeping Call in IOS #229

Closed
stephanoparaskeva opened this issue Jun 26, 2020 · 3 comments
Closed

CallKeep Not Keeping Call in IOS #229

stephanoparaskeva opened this issue Jun 26, 2020 · 3 comments

Comments

@stephanoparaskeva
Copy link

stephanoparaskeva commented Jun 26, 2020

Background:

I followed the Wazo-React-Native-Demo line by line.
The same thing occurs in react-native-callkeep demo

Env:

  • IOS
  • React Native 0.62.2
  • CallKeep 3.0.15

Explanation

  • Outgoing Calls display No UI
  • Incoming calls successfully display UI
  • Accept Incoming call makes Native Call UI go to background

Goal

  • I want to see Native UI when making Outgoing Call
  • I want to see Native UI when accepting call (Not for it to be backgrounded.)

Steps

  • Start a Call on Phone A to call Phone B
  • Phone A displays nothing. Phone B displays incoming call.
  • Accept call on Phone B. Now Phone B shows nothing. Call hides in the background for Phone B.

Example:

Phone A makes call (No UI), Phone B sees Incoming Call UI, Phone B accepts, Phone B UI disappears to background Tab.

Phone A

phonaA

Phone B

phoneB0phoneB1

Example using React-Native-Callkeep Demo

ezgif com-optimize

This is the same for Audio, and for Video

Code:

  const oneTimeId = () => {
    callId.current = callId.current || uuid();
    return callId.current;
  };

  const initializeWebRtc = async () => {
    await Wazo.Phone.connect({ audio: true, video: true });

    Wazo.Phone.on(Wazo.Phone.ON_CALL_OUTGOING, (outgoingSess: any) => {
      session.current = outgoingSess;
      const { number: num } = outgoingSess;
      RNCallKeep.startCall(oneTimeId(), num, num, 'number', false);
    });
    Wazo.Phone.on(Wazo.Phone.ON_CALL_INCOMING, (incomingSess: any) => {
      session.current = incomingSess;
      const { number: num } = incomingSess;
      RNCallKeep.displayIncomingCall(oneTimeId(), num, num, 'number', false);
    });
    Wazo.Phone.on(Wazo.Phone.ON_CALL_ACCEPTED, () => {
      // @ts-ignore
      RNCallKeep.setCurrentCallActive(oneTimeId());
      if (session.current.cameraEnabled) {
        const sipSession = Wazo.Phone.getCurrentSipSession();
        const { peerConnection } = sipSession.sessionDescriptionHandler;
        localStream.current = peerConnection
          .getLocalStreams()
          .find((stream: any) => !!stream.getVideoTracks().length);
        remoteStream.current = peerConnection
          .getRemoteStreams()
          .find((stream: any) => !!stream.getVideoTracks().length);

        dispatch({
          localStreamURL: localStream.current?.toURL() ?? null,
          remoteStreamURL: remoteStream.current?.toURL() ?? null,
        });
      }
    });
    Wazo.Phone.on(Wazo.Phone.ON_CALL_FAILED, () => {
      RNCallKeep.endCall(oneTimeId());
      callId.current = '';
      dispatch({ inCall: false });
    });
    Wazo.Phone.on(Wazo.Phone.ON_CALL_ENDED, () => {
      RNCallKeep.endCall(oneTimeId());
      callId.current = '';
      onCallTerminated();
    });
  };

  const initializeCallKeep = async () => {
    try {
      RNCallKeep.setup(options);
      RNCallKeep.setAvailable(true);
      RNCallKeep.addEventListener('didReceiveStartCallAction', onCall);
      RNCallKeep.addEventListener('answerCall', onAnswerCallAction);
      RNCallKeep.addEventListener('endCall', hangup);
    } catch (err) {
      console.warn('initializeCallKeep error:', err.message);
    }
  };

  const init = async () => {
    await initializeCallKeep();
    await initializeWebRtc();
  };
@akshitrcrm
Copy link

same with me

@akshitrcrm
Copy link

@stephanoparaskeva I think this issue is from the native Callkit framework side. I checked other apps such as whatsApp, slack, and they have their own calling UI and the behaviour is same as we are getting from this library. Even in those apps there was no way they could show the native calling screen. So I guess it's just not possible until apple does something. Do you know any app that does that?

@MrAlexWeber
Copy link

MrAlexWeber commented Feb 22, 2021

Thanks @akshitrcrm for confirming this. I was also experiencing this behavior, so it's glad to know that this is at least common if not entirely expected.

I confirmed using Facebook Messenger that when answering a call from a CallKit screen:

  • I saw the Messenger app's call screen, and
  • When I used the App Switcher, I saw a CallKit 'in call' screen.

Just to clarify, the device was unlocked with Messenger app not in the foreground. This caused the CallKit 'incoming call' UI to display.

@danjenkins I think this issue can be closed because this appears to be the usual behavior with CallKit on iOS.

@sboily sboily closed this as completed Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants