AgoraIO-Usecase / Video-Calling

Calling Interface + Connection Service on top of Agora RTM + RTC for Video Calling Example
MIT License
61 stars 43 forks source link

iOS issues in code #19

Closed seriyvolk83 closed 4 years ago

seriyvolk83 commented 4 years ago
  1. func startOutgoingCall(of session: String) is not used. Why?

  2. The following method is useless:

    func setCallConnected(of session: String) {
        let uuid = pairedUUID(of: session)
        if let call = currentCall(of: uuid), call.isOutgoing, !call.hasConnected, !call.hasEnded {
            provider.reportOutgoingCall(with: uuid, connectedAt: nil)
        }
    }

    it's called from func callCenter(_ callCenter: CallCenter, answerCall session: String) method which is called on remote side (when incoming call is accepted).

I can conclude that both sides - caller and callee are incorrectly using CallKit.

  1. I don't see provider?.reportOutgoingCall(with UUID: UUID, startedConnectingAt dateStartedConnecting: Date?) calls in the code. It should be done before provider.reportOutgoingCall(with: uuid, connectedAt: nil) call and after startOutgoingCall() on caller side.

======= for 1. you should move all code from func callingVC(_ vc:CallingViewController, startOutgoing numbers: String?) { to

func callCenter(_ callCenter: CallCenter, startCall session: String) {
        print("callCenter startCall")
// here
    }

and put startOutgoingCall(..) call into func callingVC(_ vc:CallingViewController, startOutgoing numbers: String?) {.

for 2. If provider.reportOutgoingCall(with: uuid, connectedAt: nil) is not called, then CallKit will treat the outgoing call as failed after sometime, and it will not be registered in the system. You should call it in caller when connection is established.

To fix this, you need to send a message from callee to caller in

func callCenter(_ callCenter: CallCenter, answerCall session: String)

(it's done already: inviter.accpetLastIncomingInvitation()) and call setCallConnected() on caller side in

func rtmCallKit(_ callKit: AgoraRtmCallKit, remoteInvitationAccepted remoteInvitation: AgoraRtmRemoteInvitation)

or in accepted callback in inviter.sendInvitation(peer: remoteNumber, extraContent: channel, accepted: {...}, ...)

====== PS. The main problem is that the app seems to work fine. But CallKit is completely unaware of what's going on (on both sides). For example, in case of incoming phone call during outgoing "agora video call", iOS will just show incoming phone call and it will not take into account that there is another (outgoing video) call.

seriyvolk83 commented 4 years ago

@CavanSu Let me know what do you think.

CavanSu commented 4 years ago

I have made modifications based on your suggestions, thank you. Updated on master branch