Search code examples
androidvoipsinch

Sinch Receive Call


I've been stuck on this for quite some time. I am using Sinch to establish calls.

This is the case:

  1. Working Case: Both users have opened the same activity.

User A --calls--> User B

User B <--receives call -- User A

User B receives the call.

  1. Non-Working Case: User B doesn't have the app opened. I use FCM to send the notification of the call.

User A --calls--> User B

User B <--receives call notification-- User A

User B --opens--> Call Activity -> but there is no incoming call


Caller's Code:

if (this.mCall == null) {
                mStatusInfo.setText("Calling...");
                this.mCall = this.mSinchClient.getCallClient().callUser(mRecipientId);
                this.mCall.addCallListener(new SinchCallListener());
                //Test
                String callId = this.mCall.getCallId();
                this.sendNotification(mTalkPath,mAuthor,mRecipient, callId);
}

Receivers' Code:

  private class SinchCallClientListener implements CallClientListener {
    @Override
    public void onIncomingCall(CallClient callClient, Call incomingCall) {
        //Pick up the mCall!
        mStatusInfo.setText("Incoming call...");
        mCall = incomingCall;
        mCall.addCallListener(new SinchCallListener());
        String metaData = String.format("%s, %s", mRecipient.getGender(), mRecipient.getBirthDate());
        mInfoText.setText(metaData);
    }
}

Is there any way to receive the call by using FCM? Maybe the callId can be a key to solve this?


Solution

  • Check out this https://www.sinch.com/docs/voice/android/#pushnotificationssentviayourapplicationserver

    That should give you the solution you need