Bhavik P.
Bhavik P.

Reputation: 915

Sinch didReceiveIncomingCall Never Called

I want to be able to make calls App-To-App using Sinch. I have followed the steps and converted the code into Swift. For some reason the method didReceiveIncomingCall is never called. I will paste some of my code so you can see how I initiated the SinchClient

in my viewDidLoad method I have.

sinchClient = Sinch.clientWithApplicationKey("key", applicationSecret: "secret", environmentHost: "sandbox.sinch.com", userId: "idOfUser")

sinchClient.setSupportCalling(true)
sinchClient.delegate = self
sinchClient.start()
sinchClient.startListeningOnActiveConnection()

Then I make a call from user1 to user2 using the following.

if(clientStarted){
  let callClient = sinchClient.callClient()
  callClient.callUserWithId("user2")
  sinchCall.delegate = self
}

This is my delegate methods for the SINCallClientDelegate

extension CallViewController: SINCallClientDelegate{
  func client(client: SINCallClient!, didReceiveIncomingCall call: SINCall!) {
    print("GOT ME AN INCOMING CALL")
    sinchCall = call
    sinchCall.delegate = self
    sinchCall.answer()
  }
}

For some reason, the method didRecieveIncomingCall never gets called. Sometimes I also get the following error: WARNING: Delegate for SINCallClient not assigned? Delegate should handle incoming call. (see -[SIN allClient Delegate notifyDelegate fIncomingCall:])

I think maybe it might have something to do with sinchClient.startListeningOnActiveConnection() but I am not sure.

couple things to note is that I do know when my sinchClient is started because I listen for it in my delegate. When clientDidStart is called, I change the variable for clientStarted: Bool. I also have three delegates in one file (SINCallClientDelegate, SINCallDelegate, and SINClientDelegate). It waits for sinchClient to be started before making any calls.

Upvotes: 0

Views: 761

Answers (1)

Bhavik P.
Bhavik P.

Reputation: 915

So my solution was so simple. I never set the sinchClient.callClient().delegate = self. Please read the comments on the question.

sinchClient.callClient().delegate = self
sinchClient.setSupportCalling(true)
sinchClient.delegate = self
sinchClient.start()
sinchClient.startListeningOnActiveConnection()

Upvotes: 2

Related Questions